UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'f5BSN09p8iV0JMHTz7bdygAoN8oqC57h1mH6tAw+K68=' 
WHERE 
  key_id = '9e27899783b3fc79f4c0b8f668df54e0593e318ecd8d561e72b635371b39c8b4' 
  AND (
    token = 'f5BSN09p8iV0JMHTz7bdygAoN8oqC57h1mH6tAw+K68=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048