UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'sQoLUal+A+jIA1ACSB4Ason+d2hGnESk2WRaGfj3qxs=' 
WHERE 
  key_id = '312e837d05a88faad20f3c31d2a62add726dea311d7f63dc544e2334b654d732' 
  AND (
    token = 'sQoLUal+A+jIA1ACSB4Ason+d2hGnESk2WRaGfj3qxs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048