# Class: CollectionCache

## CollectionCache

#### new CollectionCache(options) → {Object}

  Creates new cache instance.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | Collection options. ###### Properties
  Name | Type | Description
  --- | --- | ---
  `skipKey` | String | Key representing start index.
  `limitKey` | String | Key representing length of requested data.

  Source:
    - /Users/marius/Sites/libraries/collection-cache/index.js, line 19

  ##### Returns:

  - New cache instance.
  Type
    Object

  ##### Example

      var cache = new CollectionCache();

### Methods

#### add(options, data, callback)

  Add data to cache.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | Options.
  `data` | Object | Data to append to cache.
  `callback` | function | Callback accepting two parameters: `cb(err, data)`

  Source:
    - /Users/marius/Sites/libraries/collection-cache/index.js, line 96

  ##### Example

      cache.add({
        skip: 10,
        limit: 10,
      }, [1, 2], function(err, data) {
        if (err) { return console.error(err); }
        console.log(data);
      });

#### all()

  Gets all data from cache. Same as `.get()`, but returning all available data.
  Source:
    - /Users/marius/Sites/libraries/collection-cache/index.js, line 73

#### get(options, callback)

  Gets data from cache.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Object | Request options. Separate cache is used for each unique set of options. ###### Properties
  Name | Type | Description
  --- | --- | ---
  `skip` | Number | Start index of requested data.
  `limit` | Number | Length of requested data. `(endIndex - startIndex)`
  `callback` | CollectionCache~fallbackCallback | Callback accepting two parameters: `cb(err, data)`

  Source:
    - /Users/marius/Sites/libraries/collection-cache/index.js, line 52

  ##### Returns:

  - Callback result.

  ##### Example

      var result = cache.get({
        skip: 10,
        limit: 10
      });