1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/examples/simple.js
Ruben Bridgewater f1a7bcd735 chore: use standard
2017-05-06 07:06:52 +02:00

28 lines
747 B
JavaScript

'use strict'
var redis = require('redis')
var client = redis.createClient()
client.on('error', function (err) {
console.log('error event - ' + client.host + ':' + client.port + ' - ' + err)
})
client.set('string key', 'string val', console.log)
client.hset('hash key', 'hashtest 1', 'some value', console.log)
client.hset(['hash key', 'hashtest 2', 'some other value'], console.log)
client.hkeys('hash key', function (err, replies) {
if (err) {
return console.error('error response - ' + err)
}
console.log(replies.length + ' replies:')
replies.forEach(function (reply, i) {
console.log(' ' + i + ': ' + reply)
})
})
client.quit(function (err, res) {
if (err) throw err
console.log('Exiting from quit command.')
})