UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tJHEhk6tXGCrwuGW3GTRuEoJ8umjVZ0g3w0ygnF2ft8=' 
WHERE 
  key_id = 'd34f64cd5b1301b131166d18df44fc92f6e387ac02f74fef0f37cbfc2aa9798b' 
  AND (
    token = 'tJHEhk6tXGCrwuGW3GTRuEoJ8umjVZ0g3w0ygnF2ft8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037