(key, amount = 1)
| 100 | } |
| 101 | |
| 102 | async increment(key, amount = 1) { |
| 103 | if (this.useFallback) { |
| 104 | logger.debug(`[DEGRADED] Incrementing in memory: ${key}`); |
| 105 | } |
| 106 | if (this.db.increment) { |
| 107 | return this.db.increment(key, amount); |
| 108 | } |
| 109 | const current = await this.db.get(key, 0); |
| 110 | const newValue = current + amount; |
| 111 | await this.db.set(key, newValue); |
| 112 | return newValue; |
| 113 | } |
| 114 | |
| 115 | async decrement(key, amount = 1) { |
| 116 | if (this.useFallback) { |