UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'y+5ofiz0o0ziggnkHA28q3Go4UgKjHWNldgaQexfedw=' 
WHERE 
  key_id = '5314ff3715f39187fae5ced84193b6a2ea9491ac74c2c80372d9d96921f49d39' 
  AND (
    token = 'y+5ofiz0o0ziggnkHA28q3Go4UgKjHWNldgaQexfedw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027