1 # map-cache [![NPM version](https://img.shields.io/npm/v/map-cache.svg?style=flat)](https://www.npmjs.com/package/map-cache) [![NPM downloads](https://img.shields.io/npm/dm/map-cache.svg?style=flat)](https://npmjs.org/package/map-cache) [![Build Status](https://img.shields.io/travis/jonschlinkert/map-cache.svg?style=flat)](https://travis-ci.org/jonschlinkert/map-cache)
3 Basic cache object for storing key-value pairs.
7 Install with [npm](https://www.npmjs.com/):
10 $ npm install map-cache --save
13 Based on MapCache in Lo-dash v3.0. [MIT License](https://github.com/lodash/lodash/blob/master/LICENSE.txt)
18 var MapCache = require('map-cache');
19 var mapCache = new MapCache();
24 ### [MapCache](index.js#L28)
26 Creates a cache object to store key/value pairs.
31 var cache = new MapCache();
34 ### [.set](index.js#L45)
36 Adds `value` to `key` on the cache.
40 * `key` **{String}**: The key of the value to cache.
41 * `value` **{any}**: The value to cache.
42 * `returns` **{Object}**: Returns the `Cache` object for chaining.
47 cache.set('foo', 'bar');
50 ### [.get](index.js#L65)
52 Gets the cached value for `key`.
56 * `key` **{String}**: The key of the value to get.
57 * `returns` **{any}**: Returns the cached value.
66 ### [.has](index.js#L82)
68 Checks if a cached value for `key` exists.
72 * `key` **{String}**: The key of the entry to check.
73 * `returns` **{Boolean}**: Returns `true` if an entry for `key` exists, else `false`.
82 ### [.del](index.js#L98)
84 Removes `key` and its value from the cache.
88 * `key` **{String}**: The key of the value to remove.
89 * `returns` **{Boolean}**: Returns `true` if the entry was removed successfully, else `false`.
99 You might also be interested in these projects:
101 * [cache-base](https://www.npmjs.com/package/cache-base): Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects. | [homepage](https://github.com/jonschlinkert/cache-base)
102 * [config-cache](https://www.npmjs.com/package/config-cache): General purpose JavaScript object storage methods. | [homepage](https://github.com/jonschlinkert/config-cache)
103 * [option-cache](https://www.npmjs.com/package/option-cache): Simple API for managing options in JavaScript applications. | [homepage](https://github.com/jonschlinkert/option-cache)
107 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/map-cache/issues/new).
111 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
114 $ npm install verb && npm run docs
117 Or, if [verb](https://github.com/verbose/verb) is installed globally:
125 Install dev dependencies:
128 $ npm install -d && npm test
135 * [github/jonschlinkert](https://github.com/jonschlinkert)
136 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
140 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
141 Released under the [MIT license](https://github.com/jonschlinkert/map-cache/blob/master/LICENSE).
145 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 10, 2016._