diff options
| author | Itamar Rogel | 2013-06-30 21:27:42 +0300 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-07-01 12:03:10 +0100 |
| commit | 3cad63fbd86fe36b4343fa91f9317805df581f8d (patch) | |
| tree | dc20a7cde70a9704f534101ff73133100b2a5d17 /src/ng/cacheFactory.js | |
| parent | d2be5939dc7ec3b756a34175b2af5c99427411c0 (diff) | |
| download | angular.js-3cad63fbd86fe36b4343fa91f9317805df581f8d.tar.bz2 | |
docs($cacheFactory): show that you can access existing caches
Diffstat (limited to 'src/ng/cacheFactory.js')
| -rw-r--r-- | src/ng/cacheFactory.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js index 2ff02a37..39fa7d89 100644 --- a/src/ng/cacheFactory.js +++ b/src/ng/cacheFactory.js @@ -3,7 +3,20 @@ * @name ng.$cacheFactory * * @description - * Factory that constructs cache objects. + * Factory that constructs cache objects and gives access to them. + * + * <pre> + * + * var cache = $cacheFactory('cacheId'); + * expect($cacheFactory.get('cacheId')).toBe(cache); + * expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined(); + * + * cache.put("key", "value"); + * cache.put("another key", "another value"); + * + * expect(cache.info()).toEqual({id: 'cacheId', size: 2}); // Since we've specified no options on creation + * + * </pre> * * * @param {string} cacheId Name or id of the newly created cache. @@ -135,6 +148,16 @@ function $CacheFactoryProvider() { } + /** + * @ngdoc method + * @name ng.$cacheFactory#info + * @methodOf ng.$cacheFactory + * + * @description + * Get information about all the of the caches that have been created + * + * @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info` + */ cacheFactory.info = function() { var info = {}; forEach(caches, function(cache, cacheId) { @@ -144,6 +167,17 @@ function $CacheFactoryProvider() { }; + /** + * @ngdoc method + * @name ng.$cacheFactory#get + * @methodOf ng.$cacheFactory + * + * @description + * Get access to a cache object by the `cacheId` used when it was created. + * + * @param {string} cacheId Name or id of a cache to access. + * @returns {object} Cache object identified by the cacheId or undefined if no such cache. + */ cacheFactory.get = function(cacheId) { return caches[cacheId]; }; |
