3
3
* @name ng.$cacheFactory
4
4
*
5
5
* @description
6
- * Factory that constructs cache objects.
6
+ * Factory that constructs cache objects and gives access to them.
7
+ *
8
+ * <pre>
9
+ *
10
+ * var cache = $cacheFactory('cacheId');
11
+ * expect($cacheFactory.get('cacheId')).toBe(cache);
12
+ * expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined();
13
+ *
14
+ * cache.put("key", "value");
15
+ * cache.put("another key", "another value");
16
+ *
17
+ * expect(cache.info()).toEqual({id: 'cacheId', size: 2}); // Since we've specified no options on creation
18
+ *
19
+ * </pre>
7
20
*
8
21
*
9
22
* @param {string } cacheId Name or id of the newly created cache.
@@ -137,6 +150,16 @@ function $CacheFactoryProvider() {
137
150
}
138
151
139
152
153
+ /**
154
+ * @ngdoc method
155
+ * @name ng.$cacheFactory#info
156
+ * @methodOf ng.$cacheFactory
157
+ *
158
+ * @description
159
+ * Get information about all the of the caches that have been created
160
+ *
161
+ * @returns {Object } - key-value map of `cacheId` to the result of calling `cache#info`
162
+ */
140
163
cacheFactory . info = function ( ) {
141
164
var info = { } ;
142
165
forEach ( caches , function ( cache , cacheId ) {
@@ -146,6 +169,17 @@ function $CacheFactoryProvider() {
146
169
} ;
147
170
148
171
172
+ /**
173
+ * @ngdoc method
174
+ * @name ng.$cacheFactory#get
175
+ * @methodOf ng.$cacheFactory
176
+ *
177
+ * @description
178
+ * Get access to a cache object by the `cacheId` used when it was created.
179
+ *
180
+ * @param {string } cacheId Name or id of a cache to access.
181
+ * @returns {object } Cache object identified by the cacheId or undefined if no such cache.
182
+ */
149
183
cacheFactory . get = function ( cacheId ) {
150
184
return caches [ cacheId ] ;
151
185
} ;
0 commit comments