How to use redis

Comprehensive redis code examples:

How to use redis.windows:

How to use redis.sismember:

92
93
94
95
96
97
98
99
100
101
    this.project_id
  )
})

return it('should clear the doc from the DocsWithHistoryOps set', function (done) {
  rclient.sismember(
    `DocsWithHistoryOps:${this.project_id}`,
    this.doc_id,
    (error, member) => {
      if (error) return done(error)

How to use redis.get:

7
8
9
10
11
12
13
14
15
16

  redis.set('::12345678::asfasf', "safasfsaf", function (err) {
    //return callback(err);
  }, 샤드키 0 );

   redis.get('::12345678::asfasf', function (err, id) {
      console.log(id);
    //return callback(err);
  }, 샤드키 0);
*/

How to use redis.set:

3
4
5
6
7
8
9
10
11
12

// Master / Slave  Replication 구조이다.
// 따라서 write 는 Master에  read 는 Slave  에서 처리하도록 되어 있다.
// getConnection 시 write 는 Master, read 는 Slave 하도록 되어 있다

  redis.set('::12345678::asfasf', "safasfsaf", function (err) {
    //return callback(err);
  }, 샤드키 0 );

   redis.get('::12345678::asfasf', function (err, id) {

How to use redis.quit:

260
261
262
263
264
265
266
267
268
269
const _name = name || Global.defaultName
const client = Global.clients[_name]

logger.debug('kth-node-redis', {
  redis: _name,
  moment: 'app called function exported as redis.quit()',
  stack: _getStackTrace(),
})

if (client) {

How to use redis.getClient:

182
183
184
185
186
187
188
189
190
191
const _name = name || Global.defaultName
let client = Global.clients[_name]

logger.debug('kth-node-redis', {
  redis: _name,
  moment: 'app called function exported as redis.getClient()',
  note: 'deprecated function?!',
})

if (client) {

How to use redis.connectClient:

214
215
216
217
218
219
220
221
222
223
224
 * @throws
 */
function getConnectedRedisClient(clientName) {
  logger.debug('kth-node-redis', {
    redis: clientName,
    moment: 'app called function exported as redis.connectClient()',
    note: 'deprecated function?!',
  })


  const client = Global.clients[clientName]

How to use redis.createClient:

163
164
165
166
167
168
169
170
171
172
  t.end()
})

// Simulate a redis client error with `enable_offline_queue: false` and a
// quick `.set()` before the client connection ready.
var client = redis.createClient({
  host: process.env.REDIS_HOST,
  port: '6379',
  enable_offline_queue: false
})