UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ziyh6agpvJ0L6b1bEqOFOHUbBrwWTa2qm8zXtIcLKAo=' 
WHERE 
  key_id = '796f2aa082208b5225f8f187fc58b95227151cc03b83e3943f467af4c67a0a0e' 
  AND (
    token = 'ziyh6agpvJ0L6b1bEqOFOHUbBrwWTa2qm8zXtIcLKAo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040