@geekmidas/cache 0.0.6 → 0.1.0
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/README.md +68 -3
- package/dist/{chunk-DWy1uDak.cjs → chunk-CUT6urMc.cjs} +0 -9
- package/dist/expo.cjs +4 -3
- package/dist/expo.cjs.map +1 -0
- package/dist/expo.d.cts +6 -5
- package/dist/expo.d.mts +6 -5
- package/dist/expo.mjs +3 -2
- package/dist/expo.mjs.map +1 -0
- package/dist/{index-B6eF5Yxi.d.cts → index-CExVL1mV.d.cts} +7 -5
- package/dist/{index-Bv61mxVT.d.mts → index-M02PehQA.d.mts} +7 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/memory.cjs +35 -3
- package/dist/memory.cjs.map +1 -0
- package/dist/memory.d.cts +6 -5
- package/dist/memory.d.mts +6 -5
- package/dist/memory.mjs +34 -3
- package/dist/memory.mjs.map +1 -0
- package/dist/{src-DVpoP03o.mjs → src-CrE4Nl5T.mjs} +2 -1
- package/dist/src-CrE4Nl5T.mjs.map +1 -0
- package/dist/{src-C7d6HaTp.cjs → src-zfYb7mdS.cjs} +3 -2
- package/dist/src-zfYb7mdS.cjs.map +1 -0
- package/dist/upstash.cjs +32 -2
- package/dist/upstash.cjs.map +1 -0
- package/dist/upstash.d.cts +6 -5
- package/dist/upstash.d.mts +6 -5
- package/dist/upstash.mjs +31 -2
- package/dist/upstash.mjs.map +1 -0
- package/package.json +6 -2
- package/src/__benchmarks__/memory.bench.ts +51 -0
- package/src/__tests__/cache.spec.ts +31 -35
- package/src/__tests__/integration.spec.ts +32 -23
- package/src/__tests__/memory.spec.ts +1 -1
- package/src/__tests__/upstash.spec.ts +1 -1
- package/src/expo.ts +3 -4
- package/src/index.ts +5 -4
- package/src/memory.ts +6 -5
- package/src/upstash.ts +4 -4
- package/dist/__tests__/cache.spec.cjs +0 -77
- package/dist/__tests__/cache.spec.d.cts +0 -1
- package/dist/__tests__/cache.spec.d.mts +0 -1
- package/dist/__tests__/cache.spec.mjs +0 -77
- package/dist/__tests__/integration.spec.cjs +0 -235
- package/dist/__tests__/integration.spec.d.cts +0 -1
- package/dist/__tests__/integration.spec.d.mts +0 -1
- package/dist/__tests__/integration.spec.mjs +0 -235
- package/dist/__tests__/memory.spec.cjs +0 -126
- package/dist/__tests__/memory.spec.d.cts +0 -1
- package/dist/__tests__/memory.spec.d.mts +0 -1
- package/dist/__tests__/memory.spec.mjs +0 -126
- package/dist/__tests__/upstash.spec.cjs +0 -201
- package/dist/__tests__/upstash.spec.d.cts +0 -1
- package/dist/__tests__/upstash.spec.d.mts +0 -1
- package/dist/__tests__/upstash.spec.mjs +0 -201
- package/dist/magic-string.es-CBih0MJw.mjs +0 -1014
- package/dist/magic-string.es-KiPEzMtt.cjs +0 -1015
- package/dist/memory-Csy6J-Ak.cjs +0 -39
- package/dist/memory-QDTnSEX5.mjs +0 -33
- package/dist/upstash-CXy_duOa.mjs +0 -31
- package/dist/upstash-u8Hs4sZG.cjs +0 -37
- package/dist/vi.bdSIJ99Y-B-qkABPq.cjs +0 -14955
- package/dist/vi.bdSIJ99Y-CB5havZF.mjs +0 -14951
package/dist/memory-Csy6J-Ak.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
const require_src = require('./src-C7d6HaTp.cjs');
|
|
3
|
-
const date_fns = require_chunk.__toESM(require("date-fns"));
|
|
4
|
-
|
|
5
|
-
//#region src/memory.ts
|
|
6
|
-
var InMemoryCache = class {
|
|
7
|
-
store = /* @__PURE__ */ new Map();
|
|
8
|
-
expirations = /* @__PURE__ */ new Map();
|
|
9
|
-
async get(key) {
|
|
10
|
-
const expiration = await this.ttl(key);
|
|
11
|
-
if (!expiration) {
|
|
12
|
-
await this.delete(key);
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
return this.store.get(key);
|
|
16
|
-
}
|
|
17
|
-
async ttl(key) {
|
|
18
|
-
const expiration = this.expirations.get(key);
|
|
19
|
-
if (!expiration) return 0;
|
|
20
|
-
return require_src.getExpirationInSeconds(expiration);
|
|
21
|
-
}
|
|
22
|
-
async set(key, value, ttl = 600) {
|
|
23
|
-
this.store.set(key, value);
|
|
24
|
-
const now = /* @__PURE__ */ new Date();
|
|
25
|
-
const expiresAt = (0, date_fns.addSeconds)(now, ttl);
|
|
26
|
-
this.expirations.set(key, expiresAt);
|
|
27
|
-
}
|
|
28
|
-
async delete(key) {
|
|
29
|
-
this.store.delete(key);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
Object.defineProperty(exports, 'InMemoryCache', {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return InMemoryCache;
|
|
38
|
-
}
|
|
39
|
-
});
|
package/dist/memory-QDTnSEX5.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getExpirationInSeconds } from "./src-DVpoP03o.mjs";
|
|
2
|
-
import { addSeconds } from "date-fns";
|
|
3
|
-
|
|
4
|
-
//#region src/memory.ts
|
|
5
|
-
var InMemoryCache = class {
|
|
6
|
-
store = /* @__PURE__ */ new Map();
|
|
7
|
-
expirations = /* @__PURE__ */ new Map();
|
|
8
|
-
async get(key) {
|
|
9
|
-
const expiration = await this.ttl(key);
|
|
10
|
-
if (!expiration) {
|
|
11
|
-
await this.delete(key);
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
|
-
return this.store.get(key);
|
|
15
|
-
}
|
|
16
|
-
async ttl(key) {
|
|
17
|
-
const expiration = this.expirations.get(key);
|
|
18
|
-
if (!expiration) return 0;
|
|
19
|
-
return getExpirationInSeconds(expiration);
|
|
20
|
-
}
|
|
21
|
-
async set(key, value, ttl = 600) {
|
|
22
|
-
this.store.set(key, value);
|
|
23
|
-
const now = /* @__PURE__ */ new Date();
|
|
24
|
-
const expiresAt = addSeconds(now, ttl);
|
|
25
|
-
this.expirations.set(key, expiresAt);
|
|
26
|
-
}
|
|
27
|
-
async delete(key) {
|
|
28
|
-
this.store.delete(key);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
export { InMemoryCache };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Redis } from "@upstash/redis";
|
|
2
|
-
|
|
3
|
-
//#region src/upstash.ts
|
|
4
|
-
var UpstashCache = class {
|
|
5
|
-
client;
|
|
6
|
-
constructor(url, token) {
|
|
7
|
-
this.client = new Redis({
|
|
8
|
-
url,
|
|
9
|
-
token
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async ttl(key) {
|
|
13
|
-
const ttl = await this.client.ttl(key);
|
|
14
|
-
if (ttl === -2) return 0;
|
|
15
|
-
return ttl;
|
|
16
|
-
}
|
|
17
|
-
async get(key) {
|
|
18
|
-
const v = await this.client.get(key);
|
|
19
|
-
if (v === null) return void 0;
|
|
20
|
-
return v;
|
|
21
|
-
}
|
|
22
|
-
async set(key, value, ttl = 3600) {
|
|
23
|
-
await this.client.set(key, value, { ex: ttl });
|
|
24
|
-
}
|
|
25
|
-
async delete(key) {
|
|
26
|
-
await this.client.del(key);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { UpstashCache };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
const __upstash_redis = require_chunk.__toESM(require("@upstash/redis"));
|
|
3
|
-
|
|
4
|
-
//#region src/upstash.ts
|
|
5
|
-
var UpstashCache = class {
|
|
6
|
-
client;
|
|
7
|
-
constructor(url, token) {
|
|
8
|
-
this.client = new __upstash_redis.Redis({
|
|
9
|
-
url,
|
|
10
|
-
token
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
async ttl(key) {
|
|
14
|
-
const ttl = await this.client.ttl(key);
|
|
15
|
-
if (ttl === -2) return 0;
|
|
16
|
-
return ttl;
|
|
17
|
-
}
|
|
18
|
-
async get(key) {
|
|
19
|
-
const v = await this.client.get(key);
|
|
20
|
-
if (v === null) return void 0;
|
|
21
|
-
return v;
|
|
22
|
-
}
|
|
23
|
-
async set(key, value, ttl = 3600) {
|
|
24
|
-
await this.client.set(key, value, { ex: ttl });
|
|
25
|
-
}
|
|
26
|
-
async delete(key) {
|
|
27
|
-
await this.client.del(key);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
Object.defineProperty(exports, 'UpstashCache', {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return UpstashCache;
|
|
36
|
-
}
|
|
37
|
-
});
|