+ private async setValue (key: string, value: string, expirationMilliseconds?: number) {
+ const result = expirationMilliseconds !== undefined
+ ? await this.client.set(this.prefix + key, value, 'PX', expirationMilliseconds)
+ : await this.client.set(this.prefix + key, value)
+
+ if (result !== 'OK') throw new Error('Redis set result is not OK.')
+ }
+
+ private removeValue (key: string) {
+ return this.client.del(this.prefix + key)
+ }
+
+ private increment (key: string) {
+ return this.client.incr(this.prefix + key)
+ }
+
+ private async exists (key: string) {
+ const result = await this.client.exists(this.prefix + key)
+
+ return result !== 0
+ }
+
+ private setExpiration (key: string, ms: number) {
+ return this.client.expire(this.prefix + key, ms / 1000)