node-cache-redis-fork
Version:
Simplistic node redis cache ready can scale with generic-pool support
201 lines (166 loc) • 11.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>Home - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RedisCache.html">RedisCache</a><ul class='methods'><li data-type='method'><a href="RedisCache.html#del">del</a></li><li data-type='method'><a href="RedisCache.html#deleteAll">deleteAll</a></li><li data-type='method'><a href="RedisCache.html#get">get</a></li><li data-type='method'><a href="RedisCache.html#getName">getName</a></li><li data-type='method'><a href="RedisCache.html#getPoolOptions">getPoolOptions</a></li><li data-type='method'><a href="RedisCache.html#getRedisOptions">getRedisOptions</a></li><li data-type='method'><a href="RedisCache.html#getTtl">getTtl</a></li><li data-type='method'><a href="RedisCache.html#keys">keys</a></li><li data-type='method'><a href="RedisCache.html#set">set</a></li><li data-type='method'><a href="RedisCache.html#status">status</a></li><li data-type='method'><a href="RedisCache.html#wrap">wrap</a></li></ul></li><li><a href="RedisPool.html">RedisPool</a><ul class='methods'><li data-type='method'><a href="RedisPool.html#acquire">acquire</a></li><li data-type='method'><a href="RedisPool.html#availableCount">availableCount</a></li><li data-type='method'><a href="RedisPool.html#destroy">destroy</a></li><li data-type='method'><a href="RedisPool.html#drain">drain</a></li><li data-type='method'><a href="RedisPool.html#getName">getName</a></li><li data-type='method'><a href="RedisPool.html#getPoolOptions">getPoolOptions</a></li><li data-type='method'><a href="RedisPool.html#getPoolSize">getPoolSize</a></li><li data-type='method'><a href="RedisPool.html#getRedisOptions">getRedisOptions</a></li><li data-type='method'><a href="RedisPool.html#pendingCount">pendingCount</a></li><li data-type='method'><a href="RedisPool.html#release">release</a></li><li data-type='method'><a href="RedisPool.html#sendCommand">sendCommand</a></li><li data-type='method'><a href="RedisPool.html#status">status</a></li></ul></li><li><a href="RedisStore.html">RedisStore</a><ul class='methods'><li data-type='method'><a href="RedisStore.html#_executeDeleteAll">_executeDeleteAll</a></li><li data-type='method'><a href="RedisStore.html#_loadDeleteAllScript">_loadDeleteAllScript</a></li><li data-type='method'><a href="RedisStore.html#del">del</a></li><li data-type='method'><a href="RedisStore.html#deleteAll">deleteAll</a></li><li data-type='method'><a href="RedisStore.html#expire">expire</a></li><li data-type='method'><a href="RedisStore.html#get">get</a></li><li data-type='method'><a href="RedisStore.html#getName">getName</a></li><li data-type='method'><a href="RedisStore.html#getPoolOptions">getPoolOptions</a></li><li data-type='method'><a href="RedisStore.html#getRedisOptions">getRedisOptions</a></li><li data-type='method'><a href="RedisStore.html#getTtl">getTtl</a></li><li data-type='method'><a href="RedisStore.html#keys">keys</a></li><li data-type='method'><a href="RedisStore.html#ping">ping</a></li><li data-type='method'><a href="RedisStore.html#sendCommand">sendCommand</a></li><li data-type='method'><a href="RedisStore.html#set">set</a></li><li data-type='method'><a href="RedisStore.html#status">status</a></li></ul></li></ul>
</nav>
<div id="main">
<section class="readme">
<article><p><a href="https://badge.fury.io/js/node-cache-redis"><img src="https://badge.fury.io/js/node-cache-redis.svg" alt="npm version"></a>
<a href="https://travis-ci.org/pasupulaphani/node-cache-redis"><img src="https://travis-ci.org/pasupulaphani/node-cache-redis.svg?branch=master" alt="Build Status"></a>
<a href="https://coveralls.io/github/pasupulaphani/node-cache-redis?branch=master"><img src="https://coveralls.io/repos/github/pasupulaphani/node-cache-redis/badge.svg?branch=master" alt="Coverage Status"></a>
<a href="https://www.versioneye.com/user/projects/583c520dd2d44d003fb603be"><img src="https://www.versioneye.com/user/projects/583c520dd2d44d003fb603be/badge.svg?style=flat-square" alt="Dependency Status"></a>
<a href="https://gratipay.com/simple-redis-cache/"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg?style=flat-square" alt=""></a></p>
<h1>node-cache-redis <a href="https://github.com/pasupulaphani/node-cache-redis"><img src="https://github.com/themes/tactile/images/octocat-icon.png" alt="See on Github"></a></h1>
<p>Simplistic node redis cache ready can scale with generic-pool support</p>
<blockquote>
<p>Cache Early; Cache Often</p>
</blockquote>
<h2>Prerequisites</h2>
<p><code>node >= 4</code> This module requires nodejs v4 or above as it has dependencies on es6 components such as Map, Set, Promise etc.
<code>redis >= 4</code> This module requires redis v4 or above as it has dependencies on <code>UNLINK</code> and <code>redis.replicate_commands()</code> for pattern deletion.</p>
<h2>Featuring</h2>
<ul>
<li>Out of the box default configuration (but fully configurable)</li>
<li>Scalable easily, less friction during locking and purging</li>
<li>Design for multithread environment</li>
<li>Extensible Logging</li>
<li>Flexible Expiration: Through configuration, you can set a default expiration mode and time for each layer.</li>
<li>Statistics / Counters: Gather statistical information and track caching operations in Performance Monitor as needed.</li>
<li>Modular Design: Lib comes in many different packages, separating the features and dependencies.</li>
</ul>
<h5>Todo:</h5>
<ul>
<li>Serialization: Used to serialize values in distributed scenarios, can be configured.</li>
<li>Synchronized locking with a semaphore</li>
<li>Provides both sync and async API</li>
</ul>
<h3>Getting started</h3>
<pre class="prettyprint source"><code> npm install node-cache-redis
</code></pre>
<h4>Usage</h4>
<pre class="prettyprint source"><code> const RedisCache = require("node-cache-redis");
const cache = new RedisCache();
// set
cache.set("key", "value")
.then(function () {
return cache.get("key");
})
.then(function (value) {
assert.eql(value, "value")
});
</code></pre>
<h4>API</h4>
<ul>
<li>RedisCache([options])</li>
</ul>
<h4><code>options</code> object properties</h4>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">
<p>Name your store</p>
</td>
</tr>
<tr>
<td class="name"><code>redisOptions</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">
<p>opts from <a href="https://github.com/NodeRedis/node_redis#options-object-properties">node_redis#options-object-properties</a></p>
</td>
</tr>
<tr>
<td class="name"><code>poolOptions</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">
<p>opts from <a href="https://github.com/coopernurse/node-pool#createpool">node-pool#createpool</a></p>
</td>
</tr>
<tr>
<td class="name"><code>logger</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">
<p>Inject your custom logger</p>
</td>
</tr>
<tr>
<td class="name"><code>ttlInSeconds</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">
<p>Default time to live for stored values</p>
</td>
</tr>
</tbody>
</table>
<h3>Run tests</h3>
<pre><code>bash test.sh
</code></pre>
<h2>Contribute</h2>
<p><a href="https://github.com/pasupulaphani/node-cache-redis/blob/master/CONTRIBUTING.md">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a></p>
<h2>Backers</h2>
<h3>Maintainers</h3>
<p>These amazing people are maintaining this project:</p>
<ul>
<li><a href="https://github.com/pasupulaphani">Phani</a> — <a href="https://github.com/pasupulaphani/node-cache-redis/commits?author=pasupulaphani">view contributions</a></li>
</ul>
<h3>Sponsors</h3>
<p>No sponsors yet! Will you be the first?</p>
<p><a href="http://patreon.com/phaninder" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button"></a>
<a href="https://gratipay.com/~pasupulaphani/" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button"></a>
<a href="https://flattr.com/profile/pasupulaphani" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button"></a></p>
<!-- [](https://phaninder.com/paypal "Donate to this project using Paypal") -->
<!-- [](https://phaninder.com/bitcoin "Donate once-off to this project using Bitcoin") -->
<!-- [](https://phaninder.com/wishlist "Buy an item on our wishlist for us") -->
<p><a href='https://pledgie.com/campaigns/33095'><img alt='Click here to lend your support to: simple-node-redis-cache and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/33095.png?skin_name=chrome' border='0' ></a></p>
<h3>Contributors</h3>
<p>These amazing people have contributed code to this project:</p>
<ul>
<li><a href="https://github.com/oliverbrooks">Oliver Brooks</a></li>
</ul>
<p>Feel free to make changes. Please see the <a href="https://github.com/pasupulaphani/node-cache-redis/blob/master/CONTRIBUTING.md">Contributors' Guide</a> for more information on contributing to the documentation.</p>
<hr></article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>