@@ -87,6 +87,10 @@ angular.module('openshiftConsole')
87
87
// 25 is a reasonable number to keep at least one or two projects worth of data in cache
88
88
number : 25
89
89
} ) ;
90
+ this . _immutableDataCache = $cacheFactory ( 'immutableDataCache' , {
91
+ // 50 is a reasonable number for the immutable resources that are stored per resource instead of grouped by type
92
+ number : 50
93
+ } ) ;
90
94
this . _watchOptionsMap = { } ;
91
95
this . _watchWebsocketsMap = { } ;
92
96
this . _watchPollTimeoutsMap = { } ;
@@ -329,13 +333,13 @@ angular.module('openshiftConsole')
329
333
330
334
var deferred = $q . defer ( ) ;
331
335
332
- var existingData = this . _data ( key ) ;
336
+ var existingImmutableData = this . _immutableData ( key ) ;
333
337
334
338
// special case, if we have an immutable item, we can return it immediately
335
- if ( this . _hasImmutable ( resource , existingData , name ) ) {
339
+ if ( this . _hasImmutable ( resource , existingImmutableData , name ) ) {
336
340
$timeout ( function ( ) {
337
341
// we can be guaranteed this wont change on us, just send what we have in existingData
338
- deferred . resolve ( existingData . by ( 'metadata.name' ) [ name ] ) ;
342
+ deferred . resolve ( existingImmutableData . by ( 'metadata.name' ) [ name ] ) ;
339
343
} , 0 ) ;
340
344
}
341
345
else {
@@ -348,11 +352,11 @@ angular.module('openshiftConsole')
348
352
} , opts . http || { } ) )
349
353
. success ( function ( data , status , headerFunc , config , statusText ) {
350
354
if ( self . _isImmutable ( resource ) ) {
351
- if ( ! existingData ) {
352
- self . _data ( key , [ data ] ) ;
355
+ if ( ! existingImmutableData ) {
356
+ self . _immutableData ( key , [ data ] ) ;
353
357
}
354
358
else {
355
- existingData . update ( data , "ADDED" ) ;
359
+ existingImmutableData . update ( data , "ADDED" ) ;
356
360
}
357
361
}
358
362
deferred . resolve ( data ) ;
@@ -650,7 +654,7 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
650
654
var key = this . _uniqueKey ( resource , null , context , _ . get ( opts , 'http.params' ) ) ;
651
655
652
656
if ( objectCallback && objectName ) {
653
- var objectKey = this . _uniqueKey ( resource , objectName , context , _ . get ( opts , 'http.params' ) ) ;
657
+ var objectKey = this . _uniqueKey ( resource , objectName , context , _ . get ( opts , 'http.params' ) ) ;
654
658
var objCallbacks = this . _watchObjectCallbacks ( objectKey ) ;
655
659
objCallbacks . remove ( objectCallback ) ;
656
660
}
@@ -740,6 +744,13 @@ DataService.prototype.createStream = function(resource, name, context, opts, isR
740
744
this . _dataCache . get ( key ) ;
741
745
} ;
742
746
747
+ // uses $cacheFactory to impl LRU cache
748
+ DataService . prototype . _immutableData = function ( key , data ) {
749
+ return data ?
750
+ this . _immutableDataCache . put ( key , new Data ( data ) ) :
751
+ this . _immutableDataCache . get ( key ) ;
752
+ } ;
753
+
743
754
DataService . prototype . _isCached = function ( key ) {
744
755
return this . _watchInFlight ( key ) &&
745
756
this . _resourceVersion ( key ) &&
0 commit comments