UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'X3IN4QqPMRToUKZur55dEOcfetxgZkj7ah/wI8dcweA=' 
WHERE 
  key_id = 'c594334bd6914842e750e88870671232f43de7819a485cdcad5b9557753c6949' 
  AND (
    token = 'X3IN4QqPMRToUKZur55dEOcfetxgZkj7ah/wI8dcweA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024