UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'sy4U+57GxTq+y5eCE+2EG6nUiqF9WF21p9C7DshD+y4=' 
WHERE 
  key_id = '39acbd9acd982b57593513d370e16997c565ed2f3e3e3d6b99a96d4982b33290' 
  AND (
    token = 'sy4U+57GxTq+y5eCE+2EG6nUiqF9WF21p9C7DshD+y4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024