3 examples of 'redis client set' in JavaScript

Every line of 'redis client set' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
110async asyncSetex (key, expire, value) {
111 // await this._autoConnect()
112 // 统一存入json后数据
113 let valueJSON = JSON.stringify(value)
114 const { data, error } = await this.redisClient.setex(key, expire,
115 valueJSON).
116 then(data => ({ data })).
117 catch(error => ({ error }))
118 if (error) {
119 const connectFlag = await this._autoConnect()
120 if (connectFlag) {
121 return this.asyncSetex(key, expire, value)
122 }
123 }
124 await this._autoDisconnect()
125 return data
126}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

215expireAt(key, timestamp) {
216 // expireat is defined at initialization
217 return this._client.expireat(key, timestamp);
218}
23async set(key: string, value: T): Promise<void> {
24 const serialized = this.serialize(value);
25 await this.redis.hmset(this.key, key, serialized);
26}

Related snippets