UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ehOrUqxccPu9gB7X8nIQGBFRc3RwllXVazE6tU0sfX0=' 
WHERE 
  key_id = '31666e2fe02e7593fc5f06e457bf9df65ed77ba76c08873907886746529e2b35' 
  AND (
    token = 'ehOrUqxccPu9gB7X8nIQGBFRc3RwllXVazE6tU0sfX0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039