UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'JrTGGyQupo7ZjjwWUWpfAYYSzGFgIMEO9Sf5fPfnSdE=' 
WHERE 
  key_id = '5167d1c2d7f7b3977d6873e5c61310e2a3cf3caf4b3f1dfd7ee3f86970d8c240' 
  AND (
    token = 'JrTGGyQupo7ZjjwWUWpfAYYSzGFgIMEO9Sf5fPfnSdE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039