$cacheFactory
is actually not the service you want to use - it's a factory that you use to create the singleton service you want to use. Eyeballing your code, it seems like it should work. But I went ahead and created a demo to prove that it does. Here's the service:
.factory('CacheService', function($cacheFactory) {
var cache = $cacheFactory('cacheService', {
capacity: 3 // optional - turns the cache into LRU cache
});
return cache;
});
In this example, CacheService
is the singleton that has a local cache created with $cacheFactory
, which is what we return from the service. We can inject this into any controller we want and it will always return the same values.
Here's a working Plunker: http://plnkr.co/edit/loKWGms1lMCnmiWa1QA7?p=preview
If for some reason your post doesn't contain what broke your code, please feel free to update my Plunker to break it and we can go from there.