UNPKG

simple-redis-cache

Version:

Simplistic node redis cache ready can scale with generic-pool support

165 lines (129 loc) 10.7 kB
<!DOCTYPE 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#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#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#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#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><li data-type='method'><a href="RedisStore.html#ttlInSeconds">ttlInSeconds</a></li></ul></li></ul> </nav> <div id="main"> <section class="readme"> <article><p><a href="https://npmjs.org/package/simple-redis-cache"><img src="https://img.shields.io/npm/v/simple-redis-cache.svg?style=flat-square" alt="npm version"></a> <a href="https://travis-ci.org/pasupulaphani/simple-redis-cache"><img src="https://travis-ci.org/pasupulaphani/simple-redis-cache.svg?branch=master" alt="Build Status"></a> <a href="https://coveralls.io/github/pasupulaphani/simple-redis-cache?branch=master"><img src="https://coveralls.io/repos/github/pasupulaphani/simple-redis-cache/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="Gratipay donate button"></a></p> <h1>simple-redis-cache <a href="https://github.com/pasupulaphani/simple-redis-store"><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 &gt;= 4</code> This module requires nodejs v4 or above as it has dependencies on es6 components such as Map, Set, Promise etc.</p> <h2>Featuring</h2><ul> <li>Out of the box default configuration (but fully configurable)</li> <li>Provides both sync and async API</li> <li>Scalable easily, less friction during locking and purging</li> <li>Synchronized locking with a semaphore</li> <li>Design for multithread environment</li> <li>Extensible Logging</li> <li>Serialization: Used to serialize values in distributed scenarios, can be configured.</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> <h3>Getting started</h3><pre class="prettyprint source"><code> npm install simple-redis-cache</code></pre><h4>Usage</h4><pre class="prettyprint source"><code> const RedisCache = require(&quot;simple-redis-cache&quot;); const cache = new RedisCache(); // set cache.set(&quot;key&quot;, &quot;value&quot;);</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> </tbody> </table> <h3>Run tests</h3><pre class="prettyprint source"><code>bash test.sh</code></pre><h2>Contribute</h2><p><a href="https://github.com/pasupulaphani/simple-redis-cache/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/simple-redis-cache/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> <!-- [![PayPal donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://phaninder.com/paypal "Donate to this project using Paypal") --> <!-- [![Bitcoin donate button](https://img.shields.io/badge/bitcoin-donate-yellow.svg)](https://phaninder.com/bitcoin "Donate once-off to this project using Bitcoin") --> <!-- [![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)](https://phaninder.com/wishlist "Buy an item on our wishlist for us") --></p> <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/simple-redis-cache/blob/master/CONTRIBUTING.md">Contributors' Guide</a> for more information on contributing to the documentation.</p> <p><br /></p> <h2><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-57413413-5', 'auto');ga('send', 'pageview');</script></h2></article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</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>