Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fortunejs/fortune-redis
This is a Redis adapter for Fortune.
https://github.com/fortunejs/fortune-redis
data-access-layer fortune redis
Last synced: about 2 months ago
JSON representation
This is a Redis adapter for Fortune.
- Host: GitHub
- URL: https://github.com/fortunejs/fortune-redis
- Owner: fortunejs
- License: mit
- Created: 2015-10-26T13:38:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-21T22:37:11.000Z (almost 8 years ago)
- Last Synced: 2024-11-09T11:43:48.176Z (2 months ago)
- Topics: data-access-layer, fortune, redis
- Language: JavaScript
- Size: 28.3 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Code Climate](https://codeclimate.com/github/thibremy/fortune-redis/badges/gpa.svg)](https://codeclimate.com/github/thibremy/fortune-redis)
# Fortune Redis Adapter
This is a [Redis](https://http://redis.io) adapter for [Fortune](http://fortune.js.org).
This package now use [ioredis](https://github.com/luin/ioredis) instead of [node_redis](https://github.com/NodeRedis/node_redis)## Usage
Install the `fortune-redis` package from `npm`:
```git
$ npm install fortune-redis
```Then use it with Fortune:
```js
import fortune from 'fortune'
import redisAdapter from 'fortune-redis'const store = fortune({...}, {
adapter: [
redisAdapter,
{
url: 'redis://:[email protected]:6380'
}
]
})
```## Adapter Options
Event | Description
:------------- | :-------------
generateId | Generate the _id key on a new document. It must be a function that accepts one argument, the record type, and returns a unique string or number. Optional.
reateClientFactory | see belowAny node.js redis client library that conforms (or when adapted) to [ioredis](https://github.com/luin/ioredis) API can be injected into fortune-redis. You should only provide a createClientFactory function as a redis connection factory instead of providing ioredis connection options.
Below is a sample code to use fortune-redis with [ioredis-mock](https://github.com/stipsan/ioredis-mock).
```js
import fortune from 'fortune'
import redisAdapter from 'fortune-redis'
import RedisMock from 'ioredis-mock'const store = fortune({...}, {
adapter: [
redisAdapter,
{
createClientFactory() {
return new RedisMock()
}
}
]
})
```## License
This software is licensed under the MIT License.