# sails-redis-lite

> Light redis adapter for waterline. Develop for caching complecated model datas.

Latest version **0.1.1** (published 2017-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install sails-redis-lite
pnpm add sails-redis-lite
yarn add sails-redis-lite
bun add sails-redis-lite
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-02-22 |
| First published | 2016-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ethan Wu |
| Maintainers | wuyanxin |
| Keywords | redis, orm, cache, waterline, sails, sailsjs, sails.js |

## Links

- npm: https://www.npmjs.com/package/sails-redis-lite
- Repository: https://github.com/wuyanxin/sails-redis-lite
- Homepage: https://github.com/wuyanxin/sails-redis-lite#readme
- Issues: https://github.com/wuyanxin/sails-redis-lite/issues
- npm.io page: https://npm.io/package/sails-redis-lite

## Dependencies (7)

- [async](https://npm.io/package/async.md) ~1.2.0
- [redis](https://npm.io/package/redis.md) ~0.12.0
- [lodash](https://npm.io/package/lodash.md) ~3.9.0
- [hiredis](https://npm.io/package/hiredis.md) ~0.4.1
- [waterline-cursor](https://npm.io/package/waterline-cursor.md) ~0.0.5
- [waterline-errors](https://npm.io/package/waterline-errors.md) ~0.10.0
- [waterline-criteria](https://npm.io/package/waterline-criteria.md) ~0.11.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-02-22
- 0.1.0 — 2016-10-31

## README

![image_squidhome@2x.png](http://i.imgur.com/RIvu9.png)

# Light Redis Sails/Waterline Adapter 

A light Sails/Waterline adapter for Redis. May be used in a [Sails](https://github.com/balderdashy/sails) app or anything using Waterline for the ORM.

Base on the [sails-redis](https://github.com/balderdashy/sails-redis), remove the indexes and unique constraints, add expire time support. 

I develop it for caching complicated models datas which has a lot of associations.

## Install

Install is through NPM.

```bash
$ npm install sails-redis-lite
```

## Configuration

The following connection configuration is available:

```javascript
// default values inline
config: {
  port: 6379,
  host: 'localhost',
  password: null,
  database: null
};
```

Alternatively the URL notation for configuration can be used for configuration:

``` javascript
config {
  url: 'redis://h:abc123@host.com:6379'
}

// Equivalent to:
// config: {
//   port: 6379,
//   host: 'host.com'
//   password: 'abc123'
// }
// Other portions of the URL, including the 'username' 'h' are ignored
```

Note that if both the 'url' notation and the 'host', 'port' and / or 'password' notations are used, the non-url configuration options will take precedence.

### With Sails

When using this library with sails add the config below to your `config/connections.js` file:

```js
  
  redis: {
    adapter: "sails-redis-lite",
    port: 6379,
    host: 'localhost'
  }

```

And then you can make it the default by changing `config/models.js` to show:

```js
  connection: 'redis',
```

#### Low-Level Configuration (for redis driver)

Configuration for the underlying Redis driver itself is located as an object under the `options`.  The following options are available:

* `parser`: which Redis protocol reply parser to use.  Defaults to `hiredis` if that module is installed.
This may also be set to `javascript`.
* `return_buffers`: defaults to `false`.  If set to `true`, then all replies will be sent to callbacks as node Buffer
objects instead of JavaScript Strings.
* `detect_buffers`: default to `false`. If set to `true`, then replies will be sent to callbacks as node Buffer objects
if any of the input arguments to the original command were Buffer objects.
This option lets you switch between Buffers and Strings on a per-command basis, whereas `return_buffers` applies to
every command on a client.
* `socket_nodelay`: defaults to `true`. Whether to call setNoDelay() on the TCP stream, which disables the
Nagle algorithm on the underlying socket.  Setting this option to `false` can result in additional throughput at the
cost of more latency.  Most applications will want this set to `true`.
* `no_ready_check`: defaults to `false`. When a connection is established to the Redis server, the server might still
be loading the database from disk.  While loading, the server not respond to any commands.  To work around this,
`node_redis` has a "ready check" which sends the `INFO` command to the server.  The response from the `INFO` command
indicates whether the server is ready for more commands.  When ready, `node_redis` emits a `ready` event.
Setting `no_ready_check` to `true` will inhibit this check.
* `enable_offline_queue`: defaults to `true`. By default, if there is no active
connection to the redis server, commands are added to a queue and are executed
once the connection has been established. Setting `enable_offline_queue` to
`false` will disable this feature and the callback will be execute immediately
with an error, or an error will be thrown if no callback is specified.
* `retry_max_delay`: defaults to `null`. By default every time the client tries to connect and fails time before
reconnection (delay) almost doubles. This delay normally grows infinitely, but setting `retry_max_delay` limits delay
to maximum value, provided in milliseconds.
* `connect_timeout` defaults to `false`. By default client will try reconnecting until connected. Setting `connect_timeout`
limits total time for client to reconnect. Value is provided in milliseconds and is counted once the disconnect occured.
* `max_attempts` defaults to `null`. By default client will try reconnecting until connected. Setting `max_attempts`
limits total amount of reconnects.
* `auth_pass` defaults to `null`. By default client will try connecting without auth. If set, client will run redis auth command on connect.

## FAQ

See `FAQ.md`.



## Contribute

See `CONTRIBUTING.md`.


## MIT License

See `LICENSE.md`.

---
_Source: https://npm.io/package/sails-redis-lite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
