UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '36Vef/AHsctt9yWb4KHd9EyfoYRa8pYyijfy8muP8SE=' 
WHERE 
  key_id = '338fd356270335393efea6b8148acfb415eece5dcf91034cce7948af0323be49' 
  AND (
    token = '36Vef/AHsctt9yWb4KHd9EyfoYRa8pYyijfy8muP8SE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047