UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'rY1RgTyw1z3PBh6K4QEuxf7LNXOPUTvugbt1veb+RNE=' 
WHERE 
  key_id = '87d58ca3870dce77a713f328e839bde1a2c44266b5358cbd15a87a6314c30cf9' 
  AND (
    token = 'rY1RgTyw1z3PBh6K4QEuxf7LNXOPUTvugbt1veb+RNE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026