Exit() { console.log('NodeQuant Exit'); global.NodeQuant.MainEngine.Stop(MainEngineStatus.Stop); // 关闭数据库连接(RedisDB) this.SystemDBClient.quit(); }
function writeCache(res,skey,sval) { var client = redis.createClient(rport,rhost); client.on('connect', function() { console.log('Redis client connected'); }); client.on('error', function (err) { console.log('Something went wrong ' + err); }); client.unref(); client.set(skey, sval, redis.print); res.send('SET: ' + skey + ' ' + sval); client.quit(); }
destroy() { this.redisClient.quit(); }
async function processRedis(filename, api, apikey) { let client = redis.createClient(); let githubData = await getGithubData(api, apikey); // Do NOT forget to stringify the JSON !! githubData = JSON.stringify(githubData); let setAsync = promisify(client.set).bind(client); let writeResult = await setAsync(filename, githubData); console.log(`${writeResult} has been saved.`); client.quit(); }
// // Close the client. // function teardown() { console.log('Shutting down YugaByte client connection for Cassandra API.'); ybCassandraClient.shutdown(); ybRedisClient.quit(function (err, res) { console.log('Shutting down YugaByte client connection for Redis API.'); }); }
sequelize.sync({ force: true }) .then(async () => { await User.create({ uuid: userUUID, username: 'idangozlan', birthday: new Date(1980, 6, 20), }); // We can use the default sequelize methods by adding suffix of "Cached" // for example, findByIdCached: const [resUser, cacheHit] = await SRUser.findByPkCached(userCacheKey, userUUID); console.log('Sequelize Redis Model:', resUser.toJSON(), cacheHit); // We can also use the non cached methods (original methods) const orgUser = await User.findByPk(userUUID); console.log('Original Model:', orgUser.toJSON()); await sequelize.close(); await redisClient.quit(); });
redisClient.get('myname', (err, val) => { if (err) { console.error(err) return } console.log('val', val) // 退出 redisClient.quit() })
client.hkeys('hash key', function (err, replies) { console.log(replies.length + ' replies:'); replies.forEach(function (reply, i) { console.log(' ' + i + ': ' + reply); }); client.quit(); });
})) }) }).then(() => client.quit())
client.on('error', () => { client.quit() console.log('Redis 引入失败,已使用临时 Object 代替缓存空间…') const pool = {} const summarize = (obj, length) => { let str = String(obj) if (str.length > length) { str = str.substring(0, length) + '...' } return str } client = { set (key, value) { pool[key] = value console.log('dev-fake-redis [set]', chalkColored.cyan(key), summarize(value, 32)) }, async getAsync (key) { let value = pool[key] || 'null' console.log('dev-fake-redis [get]', chalkColored.cyan(key), summarize(value, 32)) return value }, batchDelete (keyword) { Object.keys(pool).filter(k => ~k.indexOf(keyword)).map(key => { delete pool[key] }) } } })
function quit() { client.quit(); }
function getCache(res,skey) { var client = redis.createClient(rport,rhost); client.on('connect', function() { console.log('Redis client connected'); }); client.on('error', function (err) { console.log('Something went wrong ' + err); }); client.unref(); client.get(skey, function (err, value) { if (err) throw(err); res.send('GET: ' +skey + ' ' + value); }); client.quit(); }
client.hkeys("hash-key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { console.log(" " + i + ": " + reply); }); client.quit(); });
client.hkeys('hash key', function (err, replies) { console.log(replies.length + ' replies:'); replies.forEach(function (reply, i) { console.log(' ' + i + ': ' + reply); }); client.quit(); });