UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'z3Te/t8nTzJZPEI6aPONJynQQLprxCXD4GHsStEcvoU=' 
WHERE 
  key_id = '40fca627c22beaf852514f66a5176de97211edc8f46f6c2e4111885002996213' 
  AND (
    token = 'z3Te/t8nTzJZPEI6aPONJynQQLprxCXD4GHsStEcvoU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047