UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Yi7C+Y3LRVCRNe2ghjQcwj+KVzX+eOqXZeSlavPtMXc=' 
WHERE 
  key_id = '1c54706688764bdcde5612b34182b23bb8ed445235cd754e957596021fff06b0' 
  AND (
    token = 'Yi7C+Y3LRVCRNe2ghjQcwj+KVzX+eOqXZeSlavPtMXc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00076