@@ -16,14 +16,46 @@ angular.module('fluro.util')
16
16
17
17
//////////////////////////////////////////////////
18
18
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
+
19
39
controller . clear = function ( type ) {
40
+ console . log ( 'Clear' , type , 'cache' ) ;
41
+
20
42
var cache = $cacheFactory . get ( type + '-list' ) ;
21
43
if ( cache ) {
22
44
//console.log('CacheManager Clear Cache', type + '-list')
23
45
cache . removeAll ( ) ;
24
46
}
25
47
}
26
48
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
+
27
59
//////////////////////////////////////////////////
28
60
29
61
return controller ;
@@ -337,7 +369,7 @@ angular.module('fluro.util')
337
369
angular . module ( 'fluro.util' )
338
370
339
371
340
- . service ( 'Content' , function ( $resource , $cacheFactory , Fluro ) {
372
+ . service ( 'Content' , function ( $resource , CacheManager , Fluro ) {
341
373
342
374
343
375
//////////////////////////////////////////////////
@@ -348,13 +380,14 @@ angular.module('fluro.util')
348
380
349
381
controller . genericResource = function ( type , ignoreLoadingBar , noCache ) {
350
382
351
- var cache = $cacheFactory . get ( type + '-list' ) ;
352
-
383
+ var cache = CacheManager . get ( type ) ;
353
384
385
+ /*
354
386
if(!cache) {
355
387
//console.log('Creating ', type + '-list')
356
388
cache = $cacheFactory(type + '-list');
357
389
}
390
+ */
358
391
359
392
if ( noCache ) {
360
393
cache = false ;
@@ -382,14 +415,16 @@ angular.module('fluro.util')
382
415
383
416
controller . resource = function ( type , ignoreLoadingBar , noCache ) {
384
417
385
- var cache = $cacheFactory . get ( type + '-list' ) ;
418
+ var cache = CacheManager . get ( type ) ;
386
419
420
+ /*
387
421
//console.log('CACHE FOR', type, cache);
388
422
if(!cache) {
389
423
//console.log('Creating ', type + '-list')
390
424
391
425
cache = $cacheFactory(type + '-list');
392
426
}
427
+ */
393
428
394
429
if ( noCache ) {
395
430
cache = false ;
0 commit comments