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.
@@ -135,6 +148,16 @@ function $CacheFactoryProvider() {
135
148
}
136
149
137
150
151
+ /**
152
+ * @ngdoc method
153
+ * @name ng.$cacheFactory#info
154
+ * @methodOf ng.$cacheFactory
155
+ *
156
+ * @description
157
+ * Get information about all the of the caches that have been created
158
+ *
159
+ * @returns {Object } - key-value map of `cacheId` to the result of calling `cache#info`
160
+ */
138
161
cacheFactory . info = function ( ) {
139
162
var info = { } ;
140
163
forEach ( caches , function ( cache , cacheId ) {
@@ -144,6 +167,17 @@ function $CacheFactoryProvider() {
144
167
} ;
145
168
146
169
170
+ /**
171
+ * @ngdoc method
172
+ * @name ng.$cacheFactory#get
173
+ * @methodOf ng.$cacheFactory
174
+ *
175
+ * @description
176
+ * Get access to a cache object by the `cacheId` used when it was created.
177
+ *
178
+ * @param {string } cacheId Name or id of a cache to access.
179
+ * @returns {object } Cache object identified by the cacheId or undefined if no such cache.
180
+ */
147
181
cacheFactory . get = function ( cacheId ) {
148
182
return caches [ cacheId ] ;
149
183
} ;
0 commit comments