UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'mDYjC2187hiyilLScquLQHRKrRKbkFoijiXc+MwvxE4=' 
WHERE 
  key_id = 'cbe6cb2f82610095f1527b54cc5c85aa8c0142aee62a05728776a430c487f54e' 
  AND (
    token = 'mDYjC2187hiyilLScquLQHRKrRKbkFoijiXc+MwvxE4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040