Code Monkey home page Code Monkey logo

abstract-cache-redis's Introduction

abstract-cache-redis

This module provides a cache client that is compliant with the abstract-cache protocol. This client implements the await style of the protocol.

In addition to the API mandated by the protocol, the client exposes keys, scan, scanStream, disconnect and quit methods. These map to the ioredis methods of the same names. The disconnect and quit methods are only useful if you create the client with connection configuration instead of an already connected Redis client.

Example

// Create a client that uses ioredis to connect to `localhost:6379`.
const client = require('abstract-cache-redis')({ioredis: {}})

client.set('foo', 'foo', 1000)
  .then(() => client.has('foo'))
  .then(console.log) // true
  .then(() => client.quit())
  .catch(console.error)

client.set('foo', 'foo', 1000)
  .then(() => client.keys('fo*'))
  .then(console.log) // [ 'foo' ]
  .then(() => client.quit())
  .catch(console.error)

Options

The client factory accepts the an object with the following properties:

  • client: An already connected instance of ioredis.
  • ioredis: A regular ioredis configuration object.

Notes:

  1. client takes precedence to ioredis.
  2. At least one of the client or ioredis properties must be supplied.
  3. The user is responsible for closing the connection.

Tests

In order to run the tests for this project a local instance of Reis must be running on port 6379. A docker-compose.yml is included to facilitate this:

$ docker-compose -d up
$ tap test/*.test.js

npm test automates the above.

License

MIT License

abstract-cache-redis's People

Contributors

jsumners avatar mahendrahegde avatar trxcllnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

abstract-cache-redis's Issues

Double encodeURIComponent issue

Scenario: I use the keys function, to retrieve keys by a pattern.
The keys returned are already URIencoded.
I then use the same keys in the delete function. The keys are getting double-encoded and thus aren't found.

If this is expected behavior, it should be mentioned in the "keys" documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.