@sebspark/promise-cache 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -9
- package/dist/index.mjs +8 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -110,11 +110,8 @@ var Persistor = class {
|
|
|
110
110
|
...this.redis,
|
|
111
111
|
socket: {
|
|
112
112
|
reconnectStrategy: (retries, cause) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return Math.min(retries * 50, 1e3);
|
|
113
|
+
console.error(cause);
|
|
114
|
+
return 1e3 * 2 ** retries;
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
}).on("error", (err) => {
|
|
@@ -165,8 +162,9 @@ var Persistor = class {
|
|
|
165
162
|
return {};
|
|
166
163
|
}
|
|
167
164
|
async set(key, { value, timestamp, ttl }) {
|
|
168
|
-
if (!this.client) {
|
|
169
|
-
|
|
165
|
+
if (!this.client || !this.client.isReady) {
|
|
166
|
+
console.error("Client not ready");
|
|
167
|
+
return;
|
|
170
168
|
}
|
|
171
169
|
try {
|
|
172
170
|
const serializedData = JSON.stringify({ value, ttl, timestamp });
|
|
@@ -177,8 +175,9 @@ var Persistor = class {
|
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
async delete(key) {
|
|
180
|
-
if (!this.client) {
|
|
181
|
-
|
|
178
|
+
if (!this.client || !this.client.isReady) {
|
|
179
|
+
console.error("Client not ready");
|
|
180
|
+
return;
|
|
182
181
|
}
|
|
183
182
|
try {
|
|
184
183
|
await this.client.del(key);
|
package/dist/index.mjs
CHANGED
|
@@ -81,11 +81,8 @@ var Persistor = class {
|
|
|
81
81
|
...this.redis,
|
|
82
82
|
socket: {
|
|
83
83
|
reconnectStrategy: (retries, cause) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return Math.min(retries * 50, 1e3);
|
|
84
|
+
console.error(cause);
|
|
85
|
+
return 1e3 * 2 ** retries;
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
}).on("error", (err) => {
|
|
@@ -136,8 +133,9 @@ var Persistor = class {
|
|
|
136
133
|
return {};
|
|
137
134
|
}
|
|
138
135
|
async set(key, { value, timestamp, ttl }) {
|
|
139
|
-
if (!this.client) {
|
|
140
|
-
|
|
136
|
+
if (!this.client || !this.client.isReady) {
|
|
137
|
+
console.error("Client not ready");
|
|
138
|
+
return;
|
|
141
139
|
}
|
|
142
140
|
try {
|
|
143
141
|
const serializedData = JSON.stringify({ value, ttl, timestamp });
|
|
@@ -148,8 +146,9 @@ var Persistor = class {
|
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
async delete(key) {
|
|
151
|
-
if (!this.client) {
|
|
152
|
-
|
|
149
|
+
if (!this.client || !this.client.isReady) {
|
|
150
|
+
console.error("Client not ready");
|
|
151
|
+
return;
|
|
153
152
|
}
|
|
154
153
|
try {
|
|
155
154
|
await this.client.del(key);
|