Skip to content

Commit b1721ae

Browse files
committed
Cache manager updates
1 parent f9f0514 commit b1721ae

File tree

4 files changed

+79
-10
lines changed

4 files changed

+79
-10
lines changed

dist/fluro-util.js

+39-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,46 @@ angular.module('fluro.util')
1616

1717
//////////////////////////////////////////////////
1818

19+
var _caches = [];
20+
21+
//////////////////////////////////////////////////
22+
23+
controller.get = function(type) {
24+
25+
var cache = $cacheFactory.get(type + '-list');
26+
27+
28+
if(!cache) {
29+
//console.log('Creating ', type + '-list')
30+
cache = $cacheFactory(type + '-list');
31+
_caches.push(cache);
32+
}
33+
34+
return cache;
35+
}
36+
37+
//////////////////////////////////////////////////
38+
1939
controller.clear = function(type) {
40+
console.log('Clear', type, 'cache');
41+
2042
var cache = $cacheFactory.get(type +'-list');
2143
if(cache) {
2244
//console.log('CacheManager Clear Cache', type + '-list')
2345
cache.removeAll();
2446
}
2547
}
2648

49+
//////////////////////////////////////////////////
50+
51+
controller.clearAll = function() {
52+
console.log('Clear all caches')
53+
_.each(_caches, function(cache) {
54+
console.log('Clearing cache', cache);
55+
cache.removeAll();
56+
})
57+
}
58+
2759
//////////////////////////////////////////////////
2860

2961
return controller;
@@ -337,7 +369,7 @@ angular.module('fluro.util')
337369
angular.module('fluro.util')
338370

339371

340-
.service('Content', function($resource, $cacheFactory, Fluro) {
372+
.service('Content', function($resource, CacheManager, Fluro) {
341373

342374

343375
//////////////////////////////////////////////////
@@ -348,13 +380,14 @@ angular.module('fluro.util')
348380

349381
controller.genericResource = function(type, ignoreLoadingBar, noCache) {
350382

351-
var cache = $cacheFactory.get(type + '-list');
352-
383+
var cache = CacheManager.get(type);
353384

385+
/*
354386
if(!cache) {
355387
//console.log('Creating ', type + '-list')
356388
cache = $cacheFactory(type + '-list');
357389
}
390+
*/
358391

359392
if(noCache) {
360393
cache = false;
@@ -382,14 +415,16 @@ angular.module('fluro.util')
382415

383416
controller.resource = function(type, ignoreLoadingBar, noCache) {
384417

385-
var cache = $cacheFactory.get(type + '-list');
418+
var cache = CacheManager.get(type);
386419

420+
/*
387421
//console.log('CACHE FOR', type, cache);
388422
if(!cache) {
389423
//console.log('Creating ', type + '-list')
390424
391425
cache = $cacheFactory(type + '-list');
392426
}
427+
*/
393428

394429
if(noCache) {
395430
cache = false;

0 commit comments

Comments
 (0)