1.0.5 • Published 9 years ago

cacheallthethings v1.0.5

Weekly downloads
3
License
MIT
Repository
bitbucket
Last release
9 years ago

CacheAllTheThings

A Q-based Node.js library to cache things, all of them specifically in Redis or Memcached.

npm.io

Follow me on Twitter

Usage

npm install cacheallthethings --save
var CacheAllTheThings = require('cacheallthethings');

var cache = new CacheAllTheThings('redis', {
  host : '127.0.0.1',
  port : '6379',
  auth : null,
  opts : {
    namespace : 'cachebabycache'
  }
});

var cache = new CacheAllTheThings('memcached', {
  host : '127.0.0.1',
  port : '11211',
  opts : {
    namespace : 'cachebabycache'
  }
});

API

Get

  • key: Which item to retreive
cache
  .get('andrew')
  .then(
    function(val) {
      console.log('Andrew is ' + val + ' on Twitter')
    },
    function(err) {
      console.log(err);
    }
  );

Set

  • key: What to set the item in the cache under
  • object: What to cache
  • expires (optional): How long until the item expires out of the cache, in milliseconds
cache
  .set('andrew', { username : 'andrewhathaway' })
  .then(
    function() {
      console.log('Andrew has been put in the cache');
    },
    function(err) {
      console.log(err);
    }
  );

Delete

  • key: Which item to delete
cache
  .del('andrew')
  .then(
    function() {
      console.log('Andrew has been deleted from the cache');
    },
    function(err) {
      console.log(err);
    }
  );

Contributing

Fork, test, commit, open a pull request! The Vagrant box runs Redis & Memcached for testing connections etc.

License

MIT License (MIT)

Copyright (c) 2014 Andrew Hathaway

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago