UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TOGI1hvaOrMccCpGhHHou0FmJBbgX34sjwJ+nxB3bdM=' 
WHERE 
  key_id = '774f006a22fc8500566b89d0c09851d6d054fcb77041f3ac5c4d4cebda26136c' 
  AND (
    token = 'TOGI1hvaOrMccCpGhHHou0FmJBbgX34sjwJ+nxB3bdM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024