UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BAgR5EvMeNqRAtGCgOsWuTcRAgK57p8eAqxDYnaYoxU=' 
WHERE 
  key_id = '580ad3e20a4089591827e834e05ca8f761cc51e0641b3bff01a98ac69685eb1e' 
  AND (
    token = 'BAgR5EvMeNqRAtGCgOsWuTcRAgK57p8eAqxDYnaYoxU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031