Add error check for id

device_id and cache_id
are checked if they are valid.
factor out parse_cache_id.
merge