UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'CTLNspu07kjYGuUOP2gLAuDzQQN6mF+wUfsxJIAYAX0=' 
WHERE 
  key_id = '4f9da7dd23d2bfeee874e3d12b7403c08f33cea7854a84835929b118e2e16d9f' 
  AND (
    token = 'CTLNspu07kjYGuUOP2gLAuDzQQN6mF+wUfsxJIAYAX0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047