UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'a+nVqCwJA4CfvgP0NLEiDT+ulOUXN6B/D5gmq7CS3BE=' 
WHERE 
  key_id = '8107f11ac356d725a809dc927377978779a50833de4656b6c0c2239ca414623b' 
  AND (
    token = 'a+nVqCwJA4CfvgP0NLEiDT+ulOUXN6B/D5gmq7CS3BE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029