jmdobry/angular-cache

Allow more control of cache keys when using $resource

Opened this issue · 0 comments

In my application I use $resource exclusively and have cache factories configured for each distinct resource. The issue I am running into is code very far removed from the resource needs to request a brand new object. I wrapped the resource in my own object and made the cache factory available. So calling something like Resource.clearCache() will remove all cache items for that resource. This works well but of course nukes the entire cache for that resource object.

I'm not entirely sure this is possible but i would like to be able to configure a cache factory to use a specific property from the returned JSON as the cache key. For example with a Mongo DB the _id is always unique and would be great if i could tell the cache factory to use this property as the key. I could then call Resource.clearCache('my_id') and this method would attempt to clear just the cache record for that key.