{"id":13555717,"url":"https://github.com/mjackson/then-redis","last_synced_at":"2025-04-04T17:05:27.004Z","repository":{"id":7257099,"uuid":"8568867","full_name":"mjackson/then-redis","owner":"mjackson","description":"A fast, promise-based Redis client for node.js","archived":false,"fork":false,"pushed_at":"2016-08-04T17:16:45.000Z","size":201,"stargazers_count":315,"open_issues_count":7,"forks_count":43,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T06:58:05.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjackson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-05T00:55:51.000Z","updated_at":"2023-05-04T16:38:33.000Z","dependencies_parsed_at":"2022-08-31T10:11:14.320Z","dependency_job_id":null,"html_url":"https://github.com/mjackson/then-redis","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Fthen-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Fthen-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Fthen-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Fthen-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjackson","download_url":"https://codeload.github.com/mjackson/then-redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217174,"owners_count":20903008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:03:22.330Z","updated_at":"2025-04-04T17:05:26.990Z","avatar_url":"https://github.com/mjackson.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"## This package is no longer maintained. [node_redis](https://github.com/NodeRedis/node_redis) now includes support for promises in core, so this is no longer needed.\n\n# then-redis [![Travis][build-badge]][build] [![npm package][npm-badge]][npm]\n\n[build-badge]: https://img.shields.io/travis/mjackson/then-redis.svg?style=flat-square\n[build]: https://travis-ci.org/mjackson/then-redis\n\n[npm-badge]: https://img.shields.io/npm/v/then-redis.svg?style=flat-square\n[npm]: https://www.npmjs.org/package/then-redis\n\n[then-redis](https://github.com/mjackson/then-redis) is a fast, promise-based [Redis](http://redis.io) client for [node.js](http://nodejs.org). It's build on top of [node_redis](https://github.com/NodeRedis/node_redis), so it's safe and stable.\n\n## Installation\n\nUsing [npm](https://www.npmjs.com/):\n\n    $ npm install --save redis redis-commands then-redis\n\n\u003e Node version `\u003e=4` is required.\n\nThen, use as you would anything else:\n\n```js\n// using ES6 modules\nimport { createClient } from 'then-redis'\n\n// using CommonJS modules\nvar createClient = require('then-redis').createClient\n```\n\n## Usage\n\nTo create a client:\n\n```js\nimport { createClient } from 'then-redis'\n\n// Use the default config\nconst db = createClient()\n\n// Or, specify custom config with a URL\nconst db = createClient('tcp://localhost:6379')\n\n// Or, use an object config\nconst db = createClient({\n  host: 'localhost',\n  port: 6379,\n  password: 'password'\n})\n```\n\nOnce you have a client, you're ready to issue some commands. All [Redis commands](http://redis.io/commands) are present on the `Client` prototype and may be called with variable length argument lists*. Every command returns a promise for its result. [Pipelining](http://redis.io/topics/pipelining) happens automatically in most normal usage.\n\n```js\n// Simple set, incrby, and get\ndb.set('my-key', 1)\ndb.incrby('my-key', 5)\ndb.get('my-key').then(function (value) {\n  assert.strictEqual(value, 6)\n})\n\n// Multi-key set/get\ndb.mset({ a: 'one', b: 'two' })\ndb.mget('a', 'b').then(function (values) {\n  assert.deepEqual(values, [ 'one', 'two' ])\n})\n\n// Sets\ndb.sadd('my-set', 1, 2, 3)\ndb.sismember('my-set', 2).then(function (value) {\n  assert.strictEqual(value, 1)\n})\n\n// Hashes\nvar originalHash = { a: 'one', b: 'two' }\ndb.hmset('my-hash', originalHash)\ndb.hgetall('my-hash').then(function (hash) {\n  assert.deepEqual(hash, originalHash)\n})\n\n// Transactions\ndb.multi()\ndb.incr('first-key')\ndb.incr('second-key')\ndb.exec().then(function (reply) {\n  assert.deepEqual(reply, [ 1, 1 ])\n})\n\n// Pubsub\nvar subscriber = redis.createClient()\nsubscriber.on('message', function (channel, message) {\n  console.log('Received message: ' + message)\n})\nsubscriber.subscribe('my-channel').then(function () {\n  db.publish('my-channel', 'a message')\n})\n```\n\nIf you don't like the variable-length argument lists, or you already have an array of arguments that you need to pass to a command, you can always call `client.send()` directly. It takes two arguments: 1) the name of the Redis command and 2) an array of command arguments.\n\n```js\ndb.send('get', [ 'my-key' ])\ndb.send('incrby', [ 'my-key', 5 ])\ndb.send('mset', [ 'a', 'one', 'b', 'two' ])\n```\n\n\\* `INFO`, `MGET`, `MSET`, `MSETNX`, `HMSET`, `HGETALL`, `LPUSH`, and `RPUSH` optionally accept/return JavaScript objects for convenience in dealing with Redis' multi-key and hash APIs\n\n## Compatibility\n\nFor best results, it is recommended that you use Redis 2.6 or above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjackson%2Fthen-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjackson%2Fthen-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjackson%2Fthen-redis/lists"}