This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 14
14
* @returns {object } Newly created cache object with the following set of methods:
15
15
*
16
16
* - `{object}` `info()` — Returns id, size, and options of cache.
17
- * - `{void }` `put({string} key, {*} value)` — Puts a new key-value pair into the cache.
17
+ * - `{{*} }` `put({string} key, {*} value)` — Puts a new key-value pair into the cache.
18
18
* - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss.
19
19
* - `{void}` `remove({string} key)` — Removes a key-value pair from the cache.
20
20
* - `{void}` `removeAll()` — Removes all cached values.
@@ -46,13 +46,15 @@ function $CacheFactoryProvider() {
46
46
47
47
refresh ( lruEntry ) ;
48
48
49
- if ( isUndefined ( value ) ) return ;
49
+ if ( isUndefined ( value ) ) return value ;
50
50
if ( ! ( key in data ) ) size ++ ;
51
51
data [ key ] = value ;
52
52
53
53
if ( size > capacity ) {
54
54
this . remove ( staleEnd . key ) ;
55
55
}
56
+
57
+ return value ;
56
58
} ,
57
59
58
60
Original file line number Diff line number Diff line change @@ -99,6 +99,12 @@ describe('$cacheFactory', function() {
99
99
cache . remove ( 123 ) ;
100
100
expect ( cache . info ( ) . size ) . toBe ( 0 ) ;
101
101
} ) ) ;
102
+
103
+ it ( "should return value from put" , inject ( function ( $cacheFactory ) {
104
+ function DummyClass ( ) { }
105
+ var obj = new DummyClass ( ) ;
106
+ expect ( cache . put ( 'k1' , obj ) ) . toBe ( obj ) ;
107
+ } ) ) ;
102
108
} ) ;
103
109
104
110
You can’t perform that action at this time.
0 commit comments