## .cache(key, value, [id])
Cache collection or single objects
**Kind**: static function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| key | string | number | | Key for the cache storage |
| value | Object | Array.<Object> | | Collection or single object to cache |
| [id] | string | "id" | Name of the attribute to identify uniqueness of objects in collection |
**Example**
```js
// Cache single object
Cacher.cache('test', { name: 'tom' });
```
**Example**
```js
// Cache collection
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
```
**Example**
```js
// Cache overwrite
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.cache('test', [{ id: 2, name: 'carl' }]);
Cacher.hit('test'); // [{ id: 1, name: 'tom' }, { id: 2, name: 'carl' }]
```
## .hit(key, [ids]) ⇒ object | Array.<object> | null
Find cached objects
**Kind**: static function
**Returns**: object | Array.<object> | null - If ids parameter is a number, single object will be returned.
If ids parameter is array of keys, array of objects will be returned.
null will be returned when no caches are hit.
| Param | Type | Description |
| --- | --- | --- |
| key | string | number | Key for the cache storage |
| [ids] | number | Array.<number> | string | Array.<string> | id or array of ids to find cache Will get all cached objects if this parameter is not passed |
**Example**
```js
// Hit single object from collection
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.hit('test', 2); // { id: 2, name: 'john' }
```
**Example**
```js
// Hit multiple objects from collection
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.hit('test', [1, 2]); // [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]
```
**Example**
```js
// Cache miss
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, tom: 'john' }]);
Cacher.hit('test', [999]); // []
```
## .delete(key, [ids])
Delete cached objects
**Kind**: static function
| Param | Type | Description |
| --- | --- | --- |
| key | string | number | Key for the cache storage |
| [ids] | number | Array.<number> | string | Array.<string> | id or array of ids to delete from cache Will delete all cached objects if this parameter is not passed |
**Example**
```js
// Delete single object from collection
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.delete('test', 2);
Cacher.hit('test'); // [{ id: 1, name: 'tom' }]
```
**Example**
```js
// Delete multiple objects from collection
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.delete('test', [1, 2]);
Cacher.hit('test'); // []
```
**Example**
```js
// Delete all
Cacher.cache('test', [{ id: 1, name: 'tom' }, { id: 2, name: 'john' }]);
Cacher.delete('test');
Cacher.hit('test'); // []
```