A light Sails/Waterline adapter for Redis. May be used in a Sails app or anything using Waterline for the ORM.
Base on the 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 is through NPM.
$ npm install sails-redis-liteThe following connection configuration is available:
// default values inline
config: {
port: 6379,
host: 'localhost',
password: null,
database: null
};Alternatively the URL notation for configuration can be used for configuration:
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 ignoredNote that if both the 'url' notation and the 'host', 'port' and / or 'password' notations are used, the non-url configuration options will take precedence.
When using this library with sails add the config below to your config/connections.js file:
redis: {
adapter: "sails-redis-lite",
port: 6379,
host: 'localhost'
}And then you can make it the default by changing config/models.js to show:
connection: 'redis',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 tohiredisif that module is installed. This may also be set tojavascript.return_buffers: defaults tofalse. If set totrue, then all replies will be sent to callbacks as node Buffer objects instead of JavaScript Strings.detect_buffers: default tofalse. If set totrue, 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, whereasreturn_buffersapplies to every command on a client.socket_nodelay: defaults totrue. Whether to call setNoDelay() on the TCP stream, which disables the Nagle algorithm on the underlying socket. Setting this option tofalsecan result in additional throughput at the cost of more latency. Most applications will want this set totrue.no_ready_check: defaults tofalse. 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_redishas a "ready check" which sends theINFOcommand to the server. The response from theINFOcommand indicates whether the server is ready for more commands. When ready,node_redisemits areadyevent. Settingno_ready_checktotruewill inhibit this check.enable_offline_queue: defaults totrue. 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. Settingenable_offline_queuetofalsewill 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 tonull. By default every time the client tries to connect and fails time before reconnection (delay) almost doubles. This delay normally grows infinitely, but settingretry_max_delaylimits delay to maximum value, provided in milliseconds.connect_timeoutdefaults tofalse. By default client will try reconnecting until connected. Settingconnect_timeoutlimits total time for client to reconnect. Value is provided in milliseconds and is counted once the disconnect occured.max_attemptsdefaults tonull. By default client will try reconnecting until connected. Settingmax_attemptslimits total amount of reconnects.auth_passdefaults tonull. By default client will try connecting without auth. If set, client will run redis auth command on connect.
See FAQ.md.
See CONTRIBUTING.md.
See LICENSE.md.
