Skip to content

jmdobry/angular-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d9c1466 · Oct 6, 2013
Sep 24, 2013
Oct 6, 2013
Oct 6, 2013
Jul 10, 2013
Aug 3, 2013
Jul 2, 2013
Jun 16, 2013
Sep 24, 2013
Jul 10, 2013
Sep 26, 2013
May 19, 2013
Sep 24, 2013
Sep 24, 2013
Sep 21, 2013
Sep 25, 2013
Sep 21, 2013

Repository files navigation

angular-cache (2.0.0-SNAPSHOT) is a very useful replacement for Angular's $cacheFactory.

Check out the demo for a quick introduction, or continue on down for more detailed information.

The goal of the project is to solve a general problem, not satisfy a specific scenario.

See TRANSITION.md for upgrading from 1.x.x to 2.x.x.

Quick Introduction

$cacheFactory
// Angular's provided $cacheFactory
app.service('myService', function ($cacheFactory) {
    // This is all you can do with $cacheFactory
    $cacheFactory('myNewCache', { capacity: 1000 }); // This cache can hold 1000 items
});

vs

$angularCacheFactory
// Smarter caching with $angularCacheFactory
app.service('myService', function ($angularCacheFactory) {
    $angularCacheFactory('myNewCache', {
        capacity: 1000,  // This cache can hold 1000 items,
        maxAge: 90000, // Items added to this cache expire after 15 minutes
        deleteOnExpire: 'aggressive', // Items will be actively deleted when they expire
        cacheFlushInterval: 3600000, // This cache will clear itself every hour,
        storageMode: 'localStorage' // This cache will sync itself with localStorage,
        onExpire: function (key, value) {
            // This callback is executed when the item specified by "key" expires.
            // At this point you could retrieve a fresh value for "key"
            // from the server and re-insert it into the cache.
        }
     });
});

Table of Contents

  1. Demo
  2. Configuration Parameters
  3. $angularCacheFactoryProvider
  4. $angularCacheFactory
  5. AngularCache
  6. Status
  7. Download
  8. Install
  9. Usage
  10. Changelog
  11. Contributing
  12. License

Configuration Parameters

storageMode

Type: String

Default: "none"

Possible Values:

  • "none" - The cache will not sync itself with web storage.
  • "localStorage" - Sync with localStorage
  • "sessionStorage" - Sync with sessionStorage

Description: Configure the cache to sync itself with localStorage or sessionStorage. The cache will re-initialize itself from localStorage or sessionStorage on page refresh.

Usage:

$angularCacheFactory('newCache', {
    storageMode: 'localStorage'
}); // this cache will sync itself to localStorage

See Using angular-cache with localStorage.

localStorageImpl and sessionStorageImpl

Type: Object

Default: null

Description: When storageMode is set to "localStorage" or "sessionStorage" angular-cache will default to using the global localStorage and sessionStorage objects. The angular-cache localStorageImpl and sessionStorageImpl configuration parameters allow you to tell angular-cache which implementation of localStorage or sessionStorage to use. This is useful when you don't want to override the global storage objects or when using angular-cache in a browser that doesn't support localStorage or sessionStorage.

Usage:

$angularCacheFactory('newCache', {
    localStorageImpl: myLocalStorageImplementation,
    storageMode: 'localStorage'
});

$angularCacheFactory('otherCache', {
    localStorageImpl: mySessionStorageImplementation,
    storageMode: 'sessionStorage'
});

Note: If angular-cache doesn't detect a global localStorage or sessionStorage and you don't provide a polyfill, then syncing with web storage will be disabled. It is up to the developer to provide a polyfill for browsers that don't support localStorage and sessionStorage. Any implementation of localStorage and sessionStorage provided to angular-cache must implement at least the setItem, getItem, and removeItem methods.

See Using angular-cache with localStorage.

maxAge

Type: Number

Default: null

Description: Set a default maximum lifetime on all items added to the cache. They will be removed aggressively or passively or not at all depending on the value of deleteOnExpire (see below). Can be configured on a per-item basis for greater specificity.

Usage:

$angularCacheFactory('newCache', { maxAge: 36000 });

deleteOnExpire

Type: String

Default: "none"

Possible Values:

  • "none" - Items will not be removed from the cache even if they have expired.
  • "passive" - Items will be deleted if they are requested after they have expired, resulting in a miss.
  • "aggressive" - Items will be deleted as soon as they expire.

Description: maxAge must be set in order for "passive" or "aggressive" to have any effect. Can be configured on a per-item basis for greater specificity.

Usage:

$angularCacheFactory('newCache', {
    maxAge: 36000,
    deleteOnExpire: 'aggressive'
});

cacheFlushInterval

Type: Number

Default: null

Description: Set the cache to periodically clear itself.

Usage:

$angularCacheFactory('newCache', { cacheFlushInterval: 57908 });

onExpire

Type: Function

Default: null

Description: A callback function to be executed when an item expires.

Using 'onExpire' in passive delete mode

In passive delete mode the cache doesn't know if an item has expired until the item is requested, at which point the cache checks to see if the item has expired. If the item has expired then it is immediately removed from the cache, resulting in a "miss".

If you specify a global "onExpire" callback function, the cache will execute this function when it is discovered the item has expired, passing to the callback the key and value of the expired item.

When you actually request the expired item via myCache.get('someKey') you can also pass a second argument to get() specifying a callback that your cache's "onExpire" callback can execute when it finishes. For example:

Usage:

var newCache = $angularCacheFactory('newCache', {
    maxAge: 1000, // Items expire after 1 second, but we don't know it until the item is requested
    onExpire: function (key, value, done) {
        // "onExpire" callback for the cache.
        // The third optional parameter "done", is the second argument passed to `get()` as described above

        console.log(key + ' expired!');
        // Retrieve fresh value for "key" from server, of course you'll need to figure out
        // what the url is if key != url
        $http.get(key).success(function (data) {
            $angularCacheFactory.get('newCache').put(key, data);
            done(data); // Execute the "done" callback specified in the `get()` call
        });
    });
});

newCache.put('denver', 'broncos');

// wait a few seconds

var value = newCache.get('denver', function (value) {
    // here value is defined, because we retrieved it from the server
});
// here value is undefined because the item with
// the key "denver" has expired and was deleted from the
// cache when we requested it. The callback passed to
// "get()" will receive the new value for 'denver' which
// will be retrieved from the server. This callback
// is the "done" callback executed by the "onExpire"
// callback specified when we created the cache.

Another usage:

// We don't specify an "onExpire" callback for this cache
var newCache = $angularCacheFactory('newCache', {
    maxAge: 1000, // Items expire after 1 second, but we don't know it until the item is requested
});

newCache.put('denver', 'broncos');

// wait a few seconds

// In this cache the callback is immediately executed when
// the cache discovers that 'denver' has expired, and the
// callback is passed the key and value of the expired item.
// Here you could retrieve a new value for 'denver' from
// the server or decide to keep the old value and re-insert
// it into the cache. Specifying an "onExpire" callback for
// the cache is a good way to stay DRY.
var value = newCache.get('denver', function (key, value) {
    if (isGoodThisYear(key, value)) {
        newCache.put(key, value);
    } else {
        $http.get(key).success(function (data) {
            newCache.put(key, data);
        });
    }
});
Using 'onExpire' in aggressive delete mode

In aggressive delete mode you can't pass a second parameter to get() because your "onExpire" callback for the cache has already been executed for expired items.

Usage:

var newCache = $angularCacheFactory('newCache', {
    maxAge: 1000, // Items expire after 1 second and are immediately deleted
    onExpire: function (key, value) {
        // "onExpire" callback for the cache.
        // The third optional parameter "done", is the second argument passed to `get()` as described above

        console.log(key + ' expired!');
        // Retrieve fresh value for "key" from server, of course you'll need to figure out
        // what the url is if key != url
        $http.get(key).success(function (data) {
            $angularCacheFactory.get('newCache').put(key, data);
        });
    });
});

newCache.put('denver', 'broncos');

// wait a few seconds, during which time the "onExpire" callback is automatically executed

newCache.get('denver'); // 'broncos' or whatever was returned by the server in the "onExpire" callback

$angularCacheFactoryProvider

Description: Provider for $angularCacheFactory.

$angularCacheFactoryProvider.setCacheDefaults()

Description: Set the default configuration for all caches created by $angularCacheFactory.

Usage:

app.module('app', ['jmdobry.angular-cache'])
    .config(function ($angularCacheFactoryProvider) {
        $angularCacheFactoryProvider.setCacheDefaults({
            maxAge: 360000,
            deleteOnExpire: 'aggressive'
        });
    })
    .run(function ($angularCacheFactory) {
        var info = $angularCacheFactory.info();

        console.log(info.cacheDefaults); // output below
        /*
            {
                capacity: Number.MAX_VALUE,
                maxAge: 360000,
                deleteOnExpire: 'aggressive',
                onExpire: null,
                cacheFlushInterval: null,
                storageMode: 'none',
                localStorageImpl: null,
                sessionStorageImpl: null
            }
        */

        var newCache = $angularCacheFactory('newCache');

        newCache.info().maxAge; // 360000
        newCache.info().deleteOnExpire; // "aggressive"
    });

$angularCacheFactory

Description: Factory function for producing instances of AngularCache.

$angularCacheFactory.keySet()

Description: Return the set of keys associated with all caches in $angularCacheFactory.

Usage:

$angularCacheFactory.keySet();

$angularCacheFactory.keys()

Description: Return an array of the keys associated with all caches in $angularCacheFactory.

See Get info about a cache.

Usage:

$angularCacheFactory.keys();

AngularCache

Description: Object produced by invocations of $angularCacheFactory().

AngularCache.setOptions(options, strict)

Description: Dynamically configure a cache.

See Dynamically configure a cache.

Parameters:

options

Type: Object

Default: {}

Description: Hash of configuration options to apply to the cache.

strict

Type: Boolean

Default: false

Description: If true, any configuration options not specified in options will be set to their defaults.

Usage:

$angularCacheFactory.get('someCache').setOptions({ capacity: 4500 });

AngularCache.keySet()

Returns: Object

Description: Return the set of keys of all items the cache.

Usage:

$angularCacheFactory.get('someCache').keySet();

AngularCache.keys()

Returns: Array

Description: Return an array of the keys of all items in the cache.

See Get info about a cache.

Usage:

AngularCache.keys();

Status

Version Branch Build status Test Coverage
2.0.0-SNAPSHOT master Build Status Test Coverage
2.0.0-SNAPSHOT develop Build Status
2.0.0-SNAPSHOT all Build Status

Download

Latest Stable Version

| Type | File | Size | | ------------- | ----------------- | ------------------- | ---- | | Production | angular-cache-2.0.0-SNAPSHOT.min.js | 6 KB | | Development | angular-cache-2.0.0-SNAPSHOT.js | 34 KB |

Installation

Install with bower

bower install angular-cache

Include src/angular-cache.js on your web page after angular.js.

Manual install

Get angular-cache from the Download section and include it on your web page after angular.js.

Usage

Load angular-cache

Make sure angular-cache is included on your web page after angular.js.

angular.module('myApp', ['jmdobry.angular-cache']);

See angular-cache

Create a cache

app.service('myService', function ($angularCacheFactory) {

    // create a cache with default settings
    var myCache = $angularCacheFactory('myCache');

    // create an LRU cache with a capacity of 10
    var myLRUCache = $angularCacheFactory('myLRUCache', {
        capacity: 10
    });

    // create a cache whose items have a maximum lifetime of 10 minutes
    var myTimeLimitedCache = $angularCacheFactory('myTimeLimitedCache', {
        maxAge: 600000,
        onExpire: function (key, value, done) {
            // This callback is executed during a call to "get()" and the requested item has expired.
            // Receives the key and value of the expired item and a third argument, "done", which is
            // a callback function passed as the second argument to "get()".
            // See the "onExpire" configuration option discussed above.

            // do something, like get a fresh value from the server and put it into the cache
            if (done && typeof done === 'function') {
                done(); // pass whatever you want into done()
            }
        }
    });

    // create a cache whose items have a maximum lifetime of 10 minutes which are immediately deleted upon expiration
    var myAggressiveTimeLimitedCache = $angularCacheFactory('myAggressiveTimeLimitedCache', {
        maxAge: 600000,
        onExpire: function (key, value) {
            // This callback is executed right when items expire. Receives the key and value of expired items.
            // See the "onExpire" configuration option discussed above.

            // do something, like get a fresh value from the server and put it into the cache
        }
    });

    // create a cache that will clear itself every 10 minutes
    var myIntervalCache = $angularCacheFactory('myIntervalCache', {
        cacheFlushInterval: 600000
    });

    // create an cache with all options
    var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
        capacity: 10, // This cache can only hold 10 items.
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
        storageMode: 'localStorage', // This cache will sync itself with `localStorage`.
        localStorageImpl: myAwesomeLSImpl // This cache will use a custom implementation of localStorage.
    });
});

See $angularCacheFactory

Using angular-cache with localStorage (or sessionStorage)

Using angular-cache in browsers that support localStorage:

app.service('myService', function ($angularCacheFactory) {

    // This cache will sync itself with localStorage if it exists, otherwise it won't. Every time the
    // browser loads this app, this cache will attempt to initialize itself with any data it had
    // already saved to localStorage (or sessionStorage if you used that).
    var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
        storageMode: 'localStorage' // This cache will sync itself with `localStorage`.
    });
});

Using angular-cache in browsers that DON'T support localStorage:

Option 1 - Do nothing (the localStorage sync feature will be disabled)

Option 2 - Create/use a polyfill that provides the global localStorage and sessionStorage objects. angular-cache will attempt to use these if it finds them.

Option 3 - Tell angular-cache exactly which polyfill to use (also useful if you just want to use your own implementation/wrapper for localStorage):

app.service('myService', function ($angularCacheFactory) {

    var localStoragePolyfill = {
        getItem: function (key) { ... },
        setItem: function (key, value) { ... },
        removeItem: function (key) { ... }
    };

    // Always use the polyfill
    var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
        storageMode: 'localStorage', // This cache will sync itself with `localStorage`.
        localStorageImpl: localStoragePolyfill // angular-cache will use this polyfill instead of looking for localStorage
    });

    // Conditionally use the polyfill
    var options = {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
        storageMode: 'localStorage' // This cache will sync itself with `localStorage`.
    };
    if (!window.localStorage) {
        options.localStorageImpl = localStoragePolyfill;
    }
    var myAwesomeCache = $angularCacheFactory('myAwesomeCache', options);
});

Documentation on the interface that must be implementated by any localStorage/sessionStorage polyfill used by angular-cache can be found on the W3C Recommendation page for webstorage. The interface itself looks like:

interface Storage {
  readonly attribute unsigned long length;
  DOMString? key(unsigned long index);
  getter DOMString getItem(DOMString key);
  setter creator void setItem(DOMString key, DOMString value);
  deleter void removeItem(DOMString key);
  void clear();
};

angular-cache cares only about these three methods:

One developer suggested using store.js–a wrapper and polyfill for localStorage. However, store.js has its own API that doesn't match that of the webstorage spec, so if you want to use store.js or any other 3rd-party polyfill then you'll need to create a wrapper for it if it doesn't have the same API as localStorage. For example:

var storeJsToStandard {
  getItem: store.get,
  setItem: store.set,
  removeItem: store.remove
};

$angularCacheFactory('myNewCache', {
  storageMode: 'localStorage',
  localStorageImpl: storeJsToStandard
});

Using angular-cache with $http

Note The downside of letting $http handle caching for you is that it caches the responses (in string form) to your requests–not the JavaScript Object parsed from the response body. This means you can't interact with the data in the cache used by $http. See below for how to handle the caching yourself–giving you more control and the ability to interact with the cache (use it as a data store).

Configure $http to use a cache created by $angularCacheFactory by default:

app.run(function ($http, $angularCacheFactory) {

    $angularCacheFactory('defaultCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
    });

    $http.defaults.cache = $angularCacheFactory.get('defaultCache');
});

app.service('myService', function ($http) {
    return {
        getDataById: function (id) {
            var deferred = $q.defer(),
                start = new Date().getTime();

            $http.get('api/data/' + id, {
                cache: true
            }).success(function (data) {
                console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
                deferred.resolved(data);
            });
            return deferred.promise;
        }
    };
});

app.controller('myCtrl', function (myService) {
    myService.getDataById(1)
        .then(function (data) {
            // e.g. "time taken for request: 2375ms"
            // Data returned by this next call is already cached.
            myService.getDataById(1)
                .then(function (data) {
                    // e.g. "time taken for request: 1ms"
                });
        });
});

Tell $http to use a cache created by $angularCacheFactory for a specific request:

app.service('myService', function ($http, $angularCacheFactory) {

    $angularCacheFactory('dataCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
    });

    return {
        getDataById: function (id) {
            var deferred = $q.defer(),
                start = new Date().getTime();

            $http.get('api/data/' + id, {
                cache: $angularCacheFactory.get('dataCache')
            }).success(function (data) {
                console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
                deferred.resolved(data);
            });
            return deferred.promise;
        }
    };
});

app.controller('myCtrl', function (myService) {
    myService.getDataById(1)
        .then(function (data) {
            // e.g. "time taken for request: 2375ms"
            // Data returned by this next call is already cached.
            myService.getDataById(1)
                .then(function (data) {
                    // e.g. "time taken for request: 1ms"
                });
        });
});

Do your own caching while using the $http service:

app.service('myService', function ($http, $angularCacheFactory) {

    $angularCacheFactory('dataCache', {
        maxAge: 90000, // Items added to this cache expire after 15 minutes.
        cacheFlushInterval: 600000, // This cache will clear itself every hour.
        deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
    });

    return {
        getDataById: function (id) {
            var deferred = $q.defer(),
                start = new Date().getTime(),
                dataCache = $angularCacheFactory.get('dataCache');

            // Now that control of inserting/removing from the cache is in our hands,
            // we can interact with the data in "dataCache" outside of this context,
            // e.g. Modify the data after it has been returned from the server and
            // save those modifications to the cache.
            if (dataCache.get(id)) {
                deferred.resolve(dataCache.get(id));
            } else {
                $http.get('api/data/' + id).success(function (data) {
                        console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
                        deferred.resolved(data);
                    });
            }
            return deferred.promise;
        }
    };
});

app.controller('myCtrl', function (myService) {
    myService.getDataById(1)
        .then(function (data) {
            // e.g. "time taken for request: 2375ms"
            // Data returned by this next call is already cached.
            myService.getDataById(1)
                .then(function (data) {
                    // e.g. "time taken for request: 1ms"
                });
        });
});

Dynamically configure a cache

app.service('myService', function ($angularCacheFactory) {

    // create a cache with default settings
    var cache = $angularCacheFactory('cache', {
        capacity: 100,
        maxAge: 30000
    });

    // Add 50 items here, for example

    cache.info(); // { ..., size: 50, capacity: 100, maxAge: 3000, ... }

    cache.setOptions({
        capacity: 30
    });

    cache.info(); // { ..., size: 30, capacity: 30, maxAge: 3000, ... }
    // notice that only the 30 most recently added items remain in the cache because
    // the capacity was reduced.

    // setting the second parameter to true will cause the cache's configuration to be
    // reset to defaults before the configuration passed into setOptions() is applied to
    // the cache
    cache.setOptions({
        cacheFlushInterval: 5500
    }, true);

    cache.info(); // { ..., size: 30, cacheFlushInterval: 5500,
                  //   capacity: 1.7976931348623157e+308, maxAge: null, ... }

    cache.put('someItem', 'someValue', { maxAge: 12000, deleteOnExpire: 'aggressive' });
    cache.info('someItem'); // { timestamp: 12345678978, maxAge: 12000, deleteOnExpire: 'aggressive', isExpired: false }
});

See AngularCache#setOptions

Retrieve a cache

app.service('myOtherService', function ($angularCacheFactory) {

    var myCache = $angularCacheFactory.get('myCache');
});

See $angularCacheFactory#get

Retrieve items

myCache.get('someItem'); // { name: 'John Doe' });

// if the item is not in the cache or has expired
myCache.get('someMissingItem'); // undefined

See AngularCache#get

Add items

myCache.put('someItem', { name: 'John Doe' });

myCache.get('someItem'); // { name: 'John Doe' });

Give a specific item a maximum age

// The maxAge given to this item will override the maxAge of the cache, if any was set
myCache.put('someItem', { name: 'John Doe' }, { maxAge: 10000 });

myCache.get('someItem'); // { name: 'John Doe' });

// wait at least ten seconds
setTimeout(function() {

    myCache.get('someItem'); // undefined

}, 15000); // 15 seconds

See AngularCache#put

Remove items

myCache.put('someItem', { name: 'John Doe' });

myCache.remove('someItem');

myCache.get('someItem'); // undefined

See AngularCache#remove

Clear all items

myCache.put('someItem', { name: 'John Doe' });
myCache.put('someOtherItem', { name: 'Sally Jean' });

myCache.removeAll();

myCache.get('someItem'); // undefined
myCache.get('someOtherItem'); // undefined

See AngularCache#removeAll

Destroy a cache

myCache.destroy();

myCache.get('someItem'); // Will throw an error - Don't try to use a cache after destroying it!

$angularCacheFactory.get('myCache'); // undefined

See AngularCache#destroy

Get info about a cache

myCache.put("1", "someValue");

myCache.info(); // { id: 'myCache', size: 1 }

myCache.keys(); // ["1"]

myCache.keySet(); // { "1": "1" }

See AngularCache#info

Changelog

2.0.0 - xx October 2013
Breaking API changes
  • Swapped aggressiveDelete option for deleteOnExpire option. #30, #47
  • Changed $angularCacheFactory.info() to return an object similar to AngularCache.info() #45
  • Namespaced angular-cache module under jmdobry so it is now "jmdobry.angular-cache". #42
  • Substituted localStorageImpl and sessionStorageImpl options for just storageImpl option.
Backwards compatible API changes
  • Added ability to set global cache defaults in $angularCacheFactoryProvider. #55
Backwards compatible bug fixes
  • cacheFlushInterval doesn't clear web storage when storageMode is used. #52
  • AngularCache#info(key) should return 'undefined' if the key isn't in the cache #53
Other
  • Refactored angular-cache setOptions() internals to be less convoluted and to have better validation. #46
1.2.0 - 20 September 2013
Backwards compatible API changes
  • Added AngularCache#info(key) #43
Backwards compatible bug fixes
  • Fixed #39, #44, #49, #50
1.1.0 - 03 September 2013
Backwards compatible API changes
  • Added onExpire callback hook #27
  • Added $angularCacheFactory.removeAll() and $angularCacheFactory.clearAll() convenience methods #37, #38
Backwards compatible bug fixes
  • Fixed #36
1.0.0 - 26 August 2013
  • Closed #31 (Improved documentation)
  • Closed #32
1.0.0-rc.1 - 21 August 2013
  • Added localStorage feature #26, #29
0.9.1 - 03 August 2013
  • Fixed #25
0.9.0 - 03 August 2013
  • Added a changelog #13
  • Added documentation for installing with bower
  • Added ability to set option aggressiveDelete when creating cache and when adding items
  • Cleaned up README.md
  • Switched the demo to use Bootstrap 3
0.8.2 - 09 July 2013
  • Added CONTRIBUTING.md #22
  • Cleaned up meta data in bower.json and package.json
0.8.1 - 09 July 2013
  • Added .jshintrc
  • Cleaned up the docs a bit
  • bower.json now uses src/angular-cache.js instead of the versioned output files #21
  • From now on the tags for the project will be named using semver
0.8.0 - 08 July 2013
  • Added AngularCache.setOptions(), the ability to dynamically change the configuration of a cache #20
  • Added AngularCache.keys(), which returns an array of the keys in a cache #19
  • Added AngularCache.keySet(), which returns a hash of the keys in a cache #19
0.7.2 - June 2013
  • Added angular-cache to bower registry #7
  • Created a working demo #9 #17
  • Fixed the size not being reset to 0 when the cache clears itself #14 #16
  • Added $angularCacheFactory.keys(), which returns an array of the keys (the names of the caches) in $angularCacheFactory #18
  • Added $angularCacheFactory.keySet(), which returns a hash of the keys (the names of the caches) in $angularCacheFactory #18
0.6.1 - June 2013
  • Got the project building on TravisCI
  • Renamed the project to angular-cache #5
0.5.0 - June 2013
  • Added a roadmap to README.md #4
  • Clarify usage documentation #3
  • Wrote unit tests #2
0.4.0 - May 2013
  • Added Grunt build tasks #1

Contributing

Submitting Issues

  1. Make sure you aren't submitting a duplicate issue.
  2. Carefully describe how to reproduce the problem.
  3. Expect prompt feedback.

Submitting Pull Requests

Basic Idea
  • Checkout a new branch based on develop and name it to what you intend to do:
    • Example:
      $ git checkout -b BRANCH_NAME
      
    • Use one branch per fix/feature
    • Prefix your branch name with feature- or fix- appropriately.
  • Make your changes
    • Make sure to provide a spec for unit tests
    • Run your tests with either karma start or grunt test
    • Make sure the tests pass
  • Commit your changes
    • Please provide a git message which explains what you've done
    • Commit to the forked repository
  • Make a pull request
    • Make sure you send the PR to the develop branch
    • Travis CI is watching you!
More details

Read the detailed Contributing Guide

License

MIT License

Copyright (C) 2013 Jason Dobry

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.