UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '7EBBzaPtO1TPlrb0DAPMOIcaFRF+e3x55r4ClA469AM=' 
WHERE 
  key_id = '244de069542aec2b706ccd12c328472d9aea45d2e8986852cae6d9fbc4450e5e' 
  AND (
    token = '7EBBzaPtO1TPlrb0DAPMOIcaFRF+e3x55r4ClA469AM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031