Index

### collection-cache 2.0.0

# collection-cache

> Simple request data caching.

## Getting Started

#### Create a new cache instance

    var fruits = new CacheCollection();

#### Assuming...

    var queryParams = {
      sort: 'name',
      skip: 0,
      limit: 10
    };

#### Querying and Updating

    var deferred = $.Deferred();

    fruits.get(
      queryParams,
      function(err, cachedFruits) {
        deferred.resolve(cachedFruits);
      },
      function(addToCache) {
        $http({
          url: '/fruits',
          method: 'GET',
          params: queryParams
        }).success(function(newFruits) {
          addToCache(newFruits);
          deferred.resolve(newFruits);
        });
      }
    );

    return deferred.promise;

#### Synchronous Updates

    fruits.add(queryParams, ['apples', 'oranges']);

#### Synchronous Retrievals

    var cachedFruits = fruits.get(queryParams);

#### Clear Cache

    fruits.destroy();

## License

Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.