UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'im4uV0tihL3BN394U+bBUai0lbwgsW24Bu/C3g52pSo=' 
WHERE 
  key_id = '79f09a6117d1c4ddb29a00632e5cde1bf98b27966ce99cce9d1ce1813eca577f' 
  AND (
    token = 'im4uV0tihL3BN394U+bBUai0lbwgsW24Bu/C3g52pSo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038