UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KhcfnPuKzZIkQtSkOldIs+1Chjmp8Xh/t4TQ3M1KkcM=' 
WHERE 
  key_id = '018e469340d42de5463673e3a8c2ea5fc318eaec827cd2e08f05335fd7c2b90e' 
  AND (
    token = 'KhcfnPuKzZIkQtSkOldIs+1Chjmp8Xh/t4TQ3M1KkcM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043