UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TEeRFyru1vSa07GXXNh2K1+mDiGwFNpYuDKGokN0byk=' 
WHERE 
  key_id = '87669a8c1145de631cc5859894e619276c4dfbc91352a38e66bca1b13a4ac261' 
  AND (
    token = 'TEeRFyru1vSa07GXXNh2K1+mDiGwFNpYuDKGokN0byk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028