@geekmidas/cache 0.0.2 → 0.0.4

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.
Files changed (39) hide show
  1. package/README.md +512 -0
  2. package/dist/__tests__/cache.spec.cjs +30 -29
  3. package/dist/__tests__/cache.spec.d.cts +1 -0
  4. package/dist/__tests__/cache.spec.d.mts +1 -0
  5. package/dist/__tests__/cache.spec.mjs +18 -18
  6. package/dist/__tests__/integration.spec.cjs +45 -44
  7. package/dist/__tests__/integration.spec.d.cts +1 -0
  8. package/dist/__tests__/integration.spec.d.mts +1 -0
  9. package/dist/__tests__/integration.spec.mjs +26 -26
  10. package/dist/__tests__/memory.spec.cjs +45 -44
  11. package/dist/__tests__/memory.spec.d.cts +1 -0
  12. package/dist/__tests__/memory.spec.d.mts +1 -0
  13. package/dist/__tests__/memory.spec.mjs +23 -23
  14. package/dist/__tests__/upstash.spec.cjs +50 -49
  15. package/dist/__tests__/upstash.spec.d.cts +1 -0
  16. package/dist/__tests__/upstash.spec.d.mts +1 -0
  17. package/dist/__tests__/upstash.spec.mjs +23 -23
  18. package/dist/index-BPnJ3lrS.d.mts +25 -0
  19. package/dist/index-q3xYn8_0.d.cts +25 -0
  20. package/dist/index.d.cts +2 -0
  21. package/dist/index.d.mts +2 -0
  22. package/dist/memory.d.cts +11 -0
  23. package/dist/memory.d.mts +11 -0
  24. package/dist/memory.mjs +1 -1
  25. package/dist/upstash.d.cts +12 -0
  26. package/dist/upstash.d.mts +12 -0
  27. package/dist/upstash.mjs +1 -1
  28. package/package.json +15 -5
  29. package/src/memory.ts +1 -1
  30. package/src/upstash.ts +1 -1
  31. package/dist/magic-string.es-BvJNBYzY.mjs +0 -1014
  32. package/dist/magic-string.es-CKiDiYoS.cjs +0 -1015
  33. package/dist/vi.DgezovHB-McgltIC5.mjs +0 -13079
  34. package/dist/vi.DgezovHB-NqP74KGR.cjs +0 -13104
  35. /package/dist/{cache.cjs → index.cjs} +0 -0
  36. /package/dist/{cache.mjs → index.mjs} +0 -0
  37. /package/dist/{memory-YteQXj7m.mjs → memory-NQi0XmZ2.mjs} +0 -0
  38. /package/dist/{upstash-_05vyc5o.mjs → upstash-CTY-M8vR.mjs} +0 -0
  39. /package/src/{cache.ts → index.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { beforeEach, describe, globalExpect, it } from "../vi.DgezovHB-McgltIC5.mjs";
2
- import { InMemoryCache } from "../memory-YteQXj7m.mjs";
1
+ import { InMemoryCache } from "../memory-NQi0XmZ2.mjs";
2
+ import { beforeEach, describe, expect, it } from "vitest";
3
3
 
4
4
  //#region src/__tests__/memory.spec.ts
5
5
  describe("InMemoryCache", () => {
@@ -10,12 +10,12 @@ describe("InMemoryCache", () => {
10
10
  describe("get", () => {
11
11
  it("should return undefined for non-existent key", async () => {
12
12
  const result = await cache.get("non-existent");
13
- globalExpect(result).toBeUndefined();
13
+ expect(result).toBeUndefined();
14
14
  });
15
15
  it("should return value for existing key", async () => {
16
16
  await cache.set("test-key", "test-value");
17
17
  const result = await cache.get("test-key");
18
- globalExpect(result).toBe("test-value");
18
+ expect(result).toBe("test-value");
19
19
  });
20
20
  it("should handle different data types", async () => {
21
21
  const objectValue = {
@@ -33,17 +33,17 @@ describe("InMemoryCache", () => {
33
33
  await cache.set("array", arrayValue);
34
34
  await cache.set("number", numberValue);
35
35
  await cache.set("boolean", booleanValue);
36
- globalExpect(await cache.get("object")).toEqual(objectValue);
37
- globalExpect(await cache.get("array")).toEqual(arrayValue);
38
- globalExpect(await cache.get("number")).toBe(numberValue);
39
- globalExpect(await cache.get("boolean")).toBe(booleanValue);
36
+ expect(await cache.get("object")).toEqual(objectValue);
37
+ expect(await cache.get("array")).toEqual(arrayValue);
38
+ expect(await cache.get("number")).toBe(numberValue);
39
+ expect(await cache.get("boolean")).toBe(booleanValue);
40
40
  });
41
41
  });
42
42
  describe("set", () => {
43
43
  it("should store string value", async () => {
44
44
  await cache.set("string-key", "string-value");
45
45
  const result = await cache.get("string-key");
46
- globalExpect(result).toBe("string-value");
46
+ expect(result).toBe("string-value");
47
47
  });
48
48
  it("should store object value", async () => {
49
49
  const value = {
@@ -52,18 +52,18 @@ describe("InMemoryCache", () => {
52
52
  };
53
53
  await cache.set("object-key", value);
54
54
  const result = await cache.get("object-key");
55
- globalExpect(result).toEqual(value);
55
+ expect(result).toEqual(value);
56
56
  });
57
57
  it("should overwrite existing value", async () => {
58
58
  await cache.set("key", "initial-value");
59
59
  await cache.set("key", "updated-value");
60
60
  const result = await cache.get("key");
61
- globalExpect(result).toBe("updated-value");
61
+ expect(result).toBe("updated-value");
62
62
  });
63
63
  it("should handle null values", async () => {
64
64
  await cache.set("null-key", null);
65
65
  const result = await cache.get("null-key");
66
- globalExpect(result).toBeNull();
66
+ expect(result).toBeNull();
67
67
  });
68
68
  });
69
69
  describe("delete", () => {
@@ -71,17 +71,17 @@ describe("InMemoryCache", () => {
71
71
  await cache.set("to-delete", "value");
72
72
  await cache.delete("to-delete");
73
73
  const result = await cache.get("to-delete");
74
- globalExpect(result).toBeUndefined();
74
+ expect(result).toBeUndefined();
75
75
  });
76
76
  it("should not throw error for non-existent key", async () => {
77
- await globalExpect(cache.delete("non-existent")).resolves.not.toThrow();
77
+ await expect(cache.delete("non-existent")).resolves.not.toThrow();
78
78
  });
79
79
  it("should only delete specified key", async () => {
80
80
  await cache.set("key1", "value1");
81
81
  await cache.set("key2", "value2");
82
82
  await cache.delete("key1");
83
- globalExpect(await cache.get("key1")).toBeUndefined();
84
- globalExpect(await cache.get("key2")).toBe("value2");
83
+ expect(await cache.get("key1")).toBeUndefined();
84
+ expect(await cache.get("key2")).toBe("value2");
85
85
  });
86
86
  });
87
87
  describe("multiple operations", () => {
@@ -89,9 +89,9 @@ describe("InMemoryCache", () => {
89
89
  await cache.set("key1", "value1");
90
90
  await cache.set("key2", "value2");
91
91
  await cache.set("key3", "value3");
92
- globalExpect(await cache.get("key1")).toBe("value1");
93
- globalExpect(await cache.get("key2")).toBe("value2");
94
- globalExpect(await cache.get("key3")).toBe("value3");
92
+ expect(await cache.get("key1")).toBe("value1");
93
+ expect(await cache.get("key2")).toBe("value2");
94
+ expect(await cache.get("key3")).toBe("value3");
95
95
  });
96
96
  it("should maintain data integrity across operations", async () => {
97
97
  const data = { count: 0 };
@@ -99,25 +99,25 @@ describe("InMemoryCache", () => {
99
99
  const retrieved = await cache.get("counter");
100
100
  retrieved.count = 5;
101
101
  const original = await cache.get("counter");
102
- globalExpect(original.count).toBe(5);
102
+ expect(original.count).toBe(5);
103
103
  });
104
104
  });
105
105
  describe("edge cases", () => {
106
106
  it("should handle empty string as key", async () => {
107
107
  await cache.set("", "empty-key-value");
108
108
  const result = await cache.get("");
109
- globalExpect(result).toBe("empty-key-value");
109
+ expect(result).toBe("empty-key-value");
110
110
  });
111
111
  it("should handle special characters in keys", async () => {
112
112
  const specialKey = "key!@#$%^&*()_+{}|:\"<>?[]\\;',./?`~";
113
113
  await cache.set(specialKey, "special-value");
114
114
  const result = await cache.get(specialKey);
115
- globalExpect(result).toBe("special-value");
115
+ expect(result).toBe("special-value");
116
116
  });
117
117
  it("should handle undefined values", async () => {
118
118
  await cache.set("undefined-key", void 0);
119
119
  const result = await cache.get("undefined-key");
120
- globalExpect(result).toBeUndefined();
120
+ expect(result).toBeUndefined();
121
121
  });
122
122
  });
123
123
  });
@@ -1,16 +1,17 @@
1
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
1
2
  const require_upstash = require('../upstash-0RolGx7m.cjs');
2
- const require_vi_DgezovHB = require('../vi.DgezovHB-NqP74KGR.cjs');
3
+ const vitest = require_chunk.__toESM(require("vitest"));
3
4
 
4
5
  //#region src/__tests__/upstash.spec.ts
5
- require_vi_DgezovHB.describe("UpstashCache", () => {
6
+ (0, vitest.describe)("UpstashCache", () => {
6
7
  let cache;
7
8
  const testKeyPrefix = `test:${Date.now()}:`;
8
9
  let testKeys = [];
9
- require_vi_DgezovHB.beforeEach(() => {
10
+ (0, vitest.beforeEach)(() => {
10
11
  cache = new require_upstash.UpstashCache("http://localhost:8079", "example_token");
11
12
  testKeys = [];
12
13
  });
13
- require_vi_DgezovHB.afterEach(async () => {
14
+ (0, vitest.afterEach)(async () => {
14
15
  for (const key of testKeys) try {
15
16
  await cache.delete(key);
16
17
  } catch (error) {}
@@ -20,13 +21,13 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
20
21
  testKeys.push(key);
21
22
  return key;
22
23
  };
23
- require_vi_DgezovHB.describe("get", () => {
24
- require_vi_DgezovHB.it("should return undefined for non-existent key", async () => {
24
+ (0, vitest.describe)("get", () => {
25
+ (0, vitest.it)("should return undefined for non-existent key", async () => {
25
26
  const key = getTestKey("non-existent");
26
27
  const result = await cache.get(key);
27
- require_vi_DgezovHB.globalExpect(result).toBeUndefined();
28
+ (0, vitest.expect)(result).toBeUndefined();
28
29
  });
29
- require_vi_DgezovHB.it("should parse and return JSON value", async () => {
30
+ (0, vitest.it)("should parse and return JSON value", async () => {
30
31
  const key = getTestKey("object");
31
32
  const testValue = {
32
33
  id: 1,
@@ -34,30 +35,30 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
34
35
  };
35
36
  await cache.set(key, testValue);
36
37
  const result = await cache.get(key);
37
- require_vi_DgezovHB.globalExpect(result).toEqual(testValue);
38
+ (0, vitest.expect)(result).toEqual(testValue);
38
39
  });
39
- require_vi_DgezovHB.it("should handle string values", async () => {
40
+ (0, vitest.it)("should handle string values", async () => {
40
41
  const key = getTestKey("string");
41
42
  const testValue = "simple string";
42
43
  await cache.set(key, testValue);
43
44
  const result = await cache.get(key);
44
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
45
+ (0, vitest.expect)(result).toBe(testValue);
45
46
  });
46
- require_vi_DgezovHB.it("should handle number values", async () => {
47
+ (0, vitest.it)("should handle number values", async () => {
47
48
  const key = getTestKey("number");
48
49
  const testValue = 42;
49
50
  await cache.set(key, testValue);
50
51
  const result = await cache.get(key);
51
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
52
+ (0, vitest.expect)(result).toBe(testValue);
52
53
  });
53
- require_vi_DgezovHB.it("should handle boolean values", async () => {
54
+ (0, vitest.it)("should handle boolean values", async () => {
54
55
  const key = getTestKey("boolean");
55
56
  const testValue = true;
56
57
  await cache.set(key, testValue);
57
58
  const result = await cache.get(key);
58
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
59
+ (0, vitest.expect)(result).toBe(testValue);
59
60
  });
60
- require_vi_DgezovHB.it("should handle array values", async () => {
61
+ (0, vitest.it)("should handle array values", async () => {
61
62
  const key = getTestKey("array");
62
63
  const testArray = [
63
64
  1,
@@ -67,17 +68,17 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
67
68
  ];
68
69
  await cache.set(key, testArray);
69
70
  const result = await cache.get(key);
70
- require_vi_DgezovHB.globalExpect(result).toEqual(testArray);
71
+ (0, vitest.expect)(result).toEqual(testArray);
71
72
  });
72
- require_vi_DgezovHB.it("should handle null values as undefined", async () => {
73
+ (0, vitest.it)("should handle null values as undefined", async () => {
73
74
  const key = getTestKey("null");
74
75
  await cache.set(key, null);
75
76
  const result = await cache.get(key);
76
- require_vi_DgezovHB.globalExpect(result).toBeUndefined();
77
+ (0, vitest.expect)(result).toBeUndefined();
77
78
  });
78
79
  });
79
- require_vi_DgezovHB.describe("set", () => {
80
- require_vi_DgezovHB.it("should store and retrieve object value", async () => {
80
+ (0, vitest.describe)("set", () => {
81
+ (0, vitest.it)("should store and retrieve object value", async () => {
81
82
  const key = getTestKey("set-object");
82
83
  const testValue = {
83
84
  id: 1,
@@ -85,30 +86,30 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
85
86
  };
86
87
  await cache.set(key, testValue);
87
88
  const result = await cache.get(key);
88
- require_vi_DgezovHB.globalExpect(result).toEqual(testValue);
89
+ (0, vitest.expect)(result).toEqual(testValue);
89
90
  });
90
- require_vi_DgezovHB.it("should store and retrieve string values", async () => {
91
+ (0, vitest.it)("should store and retrieve string values", async () => {
91
92
  const key = getTestKey("set-string");
92
93
  const testValue = "test string";
93
94
  await cache.set(key, testValue);
94
95
  const result = await cache.get(key);
95
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
96
+ (0, vitest.expect)(result).toBe(testValue);
96
97
  });
97
- require_vi_DgezovHB.it("should store and retrieve number values", async () => {
98
+ (0, vitest.it)("should store and retrieve number values", async () => {
98
99
  const key = getTestKey("set-number");
99
100
  const testValue = 42;
100
101
  await cache.set(key, testValue);
101
102
  const result = await cache.get(key);
102
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
103
+ (0, vitest.expect)(result).toBe(testValue);
103
104
  });
104
- require_vi_DgezovHB.it("should store and retrieve boolean values", async () => {
105
+ (0, vitest.it)("should store and retrieve boolean values", async () => {
105
106
  const key = getTestKey("set-boolean");
106
107
  const testValue = true;
107
108
  await cache.set(key, testValue);
108
109
  const result = await cache.get(key);
109
- require_vi_DgezovHB.globalExpect(result).toBe(testValue);
110
+ (0, vitest.expect)(result).toBe(testValue);
110
111
  });
111
- require_vi_DgezovHB.it("should store and retrieve array values", async () => {
112
+ (0, vitest.it)("should store and retrieve array values", async () => {
112
113
  const key = getTestKey("set-array");
113
114
  const testArray = [
114
115
  1,
@@ -117,46 +118,46 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
117
118
  ];
118
119
  await cache.set(key, testArray);
119
120
  const result = await cache.get(key);
120
- require_vi_DgezovHB.globalExpect(result).toEqual(testArray);
121
+ (0, vitest.expect)(result).toEqual(testArray);
121
122
  });
122
- require_vi_DgezovHB.it("should not store and retrieve null values", async () => {
123
+ (0, vitest.it)("should not store and retrieve null values", async () => {
123
124
  const key = getTestKey("set-null");
124
125
  await cache.set(key, null);
125
126
  const result = await cache.get(key);
126
- require_vi_DgezovHB.globalExpect(result).toBeUndefined();
127
+ (0, vitest.expect)(result).toBeUndefined();
127
128
  });
128
- require_vi_DgezovHB.it("should overwrite existing values", async () => {
129
+ (0, vitest.it)("should overwrite existing values", async () => {
129
130
  const key = getTestKey("overwrite");
130
131
  await cache.set(key, "initial");
131
132
  await cache.set(key, "updated");
132
133
  const result = await cache.get(key);
133
- require_vi_DgezovHB.globalExpect(result).toBe("updated");
134
+ (0, vitest.expect)(result).toBe("updated");
134
135
  });
135
136
  });
136
- require_vi_DgezovHB.describe("delete", () => {
137
- require_vi_DgezovHB.it("should delete existing key", async () => {
137
+ (0, vitest.describe)("delete", () => {
138
+ (0, vitest.it)("should delete existing key", async () => {
138
139
  const key = getTestKey("delete-test");
139
140
  await cache.set(key, "value-to-delete");
140
141
  await cache.delete(key);
141
142
  const result = await cache.get(key);
142
- require_vi_DgezovHB.globalExpect(result).toBeUndefined();
143
+ (0, vitest.expect)(result).toBeUndefined();
143
144
  });
144
- require_vi_DgezovHB.it("should handle deletion of non-existent key", async () => {
145
+ (0, vitest.it)("should handle deletion of non-existent key", async () => {
145
146
  const key = getTestKey("non-existent-delete");
146
- await require_vi_DgezovHB.globalExpect(cache.delete(key)).resolves.not.toThrow();
147
+ await (0, vitest.expect)(cache.delete(key)).resolves.not.toThrow();
147
148
  });
148
- require_vi_DgezovHB.it("should only delete specified key", async () => {
149
+ (0, vitest.it)("should only delete specified key", async () => {
149
150
  const key1 = getTestKey("delete-key1");
150
151
  const key2 = getTestKey("delete-key2");
151
152
  await cache.set(key1, "value1");
152
153
  await cache.set(key2, "value2");
153
154
  await cache.delete(key1);
154
- require_vi_DgezovHB.globalExpect(await cache.get(key1)).toBeUndefined();
155
- require_vi_DgezovHB.globalExpect(await cache.get(key2)).toBe("value2");
155
+ (0, vitest.expect)(await cache.get(key1)).toBeUndefined();
156
+ (0, vitest.expect)(await cache.get(key2)).toBe("value2");
156
157
  });
157
158
  });
158
- require_vi_DgezovHB.describe("integration scenarios", () => {
159
- require_vi_DgezovHB.it("should handle round-trip operations", async () => {
159
+ (0, vitest.describe)("integration scenarios", () => {
160
+ (0, vitest.it)("should handle round-trip operations", async () => {
160
161
  const key = getTestKey("user-session");
161
162
  const testData = {
162
163
  user: {
@@ -168,9 +169,9 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
168
169
  };
169
170
  await cache.set(key, testData);
170
171
  const result = await cache.get(key);
171
- require_vi_DgezovHB.globalExpect(result).toEqual(testData);
172
+ (0, vitest.expect)(result).toEqual(testData);
172
173
  });
173
- require_vi_DgezovHB.it("should handle complex nested objects", async () => {
174
+ (0, vitest.it)("should handle complex nested objects", async () => {
174
175
  const key = getTestKey("complex");
175
176
  const complexObject = { level1: { level2: { level3: {
176
177
  data: "deep nested value",
@@ -178,9 +179,9 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
178
179
  } } } };
179
180
  await cache.set(key, complexObject);
180
181
  const result = await cache.get(key);
181
- require_vi_DgezovHB.globalExpect(result).toEqual(complexObject);
182
+ (0, vitest.expect)(result).toEqual(complexObject);
182
183
  });
183
- require_vi_DgezovHB.it("should handle concurrent operations", async () => {
184
+ (0, vitest.it)("should handle concurrent operations", async () => {
184
185
  const keys = [
185
186
  "concurrent1",
186
187
  "concurrent2",
@@ -193,7 +194,7 @@ require_vi_DgezovHB.describe("UpstashCache", () => {
193
194
  ];
194
195
  await Promise.all(keys.map((key, i) => cache.set(key, values[i])));
195
196
  const results = await Promise.all(keys.map((key) => cache.get(key)));
196
- require_vi_DgezovHB.globalExpect(results).toEqual(values);
197
+ (0, vitest.expect)(results).toEqual(values);
197
198
  });
198
199
  });
199
200
  });
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,5 +1,5 @@
1
- import { afterEach, beforeEach, describe, globalExpect, it } from "../vi.DgezovHB-McgltIC5.mjs";
2
- import { UpstashCache } from "../upstash-_05vyc5o.mjs";
1
+ import { UpstashCache } from "../upstash-CTY-M8vR.mjs";
2
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
3
 
4
4
  //#region src/__tests__/upstash.spec.ts
5
5
  describe("UpstashCache", () => {
@@ -24,7 +24,7 @@ describe("UpstashCache", () => {
24
24
  it("should return undefined for non-existent key", async () => {
25
25
  const key = getTestKey("non-existent");
26
26
  const result = await cache.get(key);
27
- globalExpect(result).toBeUndefined();
27
+ expect(result).toBeUndefined();
28
28
  });
29
29
  it("should parse and return JSON value", async () => {
30
30
  const key = getTestKey("object");
@@ -34,28 +34,28 @@ describe("UpstashCache", () => {
34
34
  };
35
35
  await cache.set(key, testValue);
36
36
  const result = await cache.get(key);
37
- globalExpect(result).toEqual(testValue);
37
+ expect(result).toEqual(testValue);
38
38
  });
39
39
  it("should handle string values", async () => {
40
40
  const key = getTestKey("string");
41
41
  const testValue = "simple string";
42
42
  await cache.set(key, testValue);
43
43
  const result = await cache.get(key);
44
- globalExpect(result).toBe(testValue);
44
+ expect(result).toBe(testValue);
45
45
  });
46
46
  it("should handle number values", async () => {
47
47
  const key = getTestKey("number");
48
48
  const testValue = 42;
49
49
  await cache.set(key, testValue);
50
50
  const result = await cache.get(key);
51
- globalExpect(result).toBe(testValue);
51
+ expect(result).toBe(testValue);
52
52
  });
53
53
  it("should handle boolean values", async () => {
54
54
  const key = getTestKey("boolean");
55
55
  const testValue = true;
56
56
  await cache.set(key, testValue);
57
57
  const result = await cache.get(key);
58
- globalExpect(result).toBe(testValue);
58
+ expect(result).toBe(testValue);
59
59
  });
60
60
  it("should handle array values", async () => {
61
61
  const key = getTestKey("array");
@@ -67,13 +67,13 @@ describe("UpstashCache", () => {
67
67
  ];
68
68
  await cache.set(key, testArray);
69
69
  const result = await cache.get(key);
70
- globalExpect(result).toEqual(testArray);
70
+ expect(result).toEqual(testArray);
71
71
  });
72
72
  it("should handle null values as undefined", async () => {
73
73
  const key = getTestKey("null");
74
74
  await cache.set(key, null);
75
75
  const result = await cache.get(key);
76
- globalExpect(result).toBeUndefined();
76
+ expect(result).toBeUndefined();
77
77
  });
78
78
  });
79
79
  describe("set", () => {
@@ -85,28 +85,28 @@ describe("UpstashCache", () => {
85
85
  };
86
86
  await cache.set(key, testValue);
87
87
  const result = await cache.get(key);
88
- globalExpect(result).toEqual(testValue);
88
+ expect(result).toEqual(testValue);
89
89
  });
90
90
  it("should store and retrieve string values", async () => {
91
91
  const key = getTestKey("set-string");
92
92
  const testValue = "test string";
93
93
  await cache.set(key, testValue);
94
94
  const result = await cache.get(key);
95
- globalExpect(result).toBe(testValue);
95
+ expect(result).toBe(testValue);
96
96
  });
97
97
  it("should store and retrieve number values", async () => {
98
98
  const key = getTestKey("set-number");
99
99
  const testValue = 42;
100
100
  await cache.set(key, testValue);
101
101
  const result = await cache.get(key);
102
- globalExpect(result).toBe(testValue);
102
+ expect(result).toBe(testValue);
103
103
  });
104
104
  it("should store and retrieve boolean values", async () => {
105
105
  const key = getTestKey("set-boolean");
106
106
  const testValue = true;
107
107
  await cache.set(key, testValue);
108
108
  const result = await cache.get(key);
109
- globalExpect(result).toBe(testValue);
109
+ expect(result).toBe(testValue);
110
110
  });
111
111
  it("should store and retrieve array values", async () => {
112
112
  const key = getTestKey("set-array");
@@ -117,20 +117,20 @@ describe("UpstashCache", () => {
117
117
  ];
118
118
  await cache.set(key, testArray);
119
119
  const result = await cache.get(key);
120
- globalExpect(result).toEqual(testArray);
120
+ expect(result).toEqual(testArray);
121
121
  });
122
122
  it("should not store and retrieve null values", async () => {
123
123
  const key = getTestKey("set-null");
124
124
  await cache.set(key, null);
125
125
  const result = await cache.get(key);
126
- globalExpect(result).toBeUndefined();
126
+ expect(result).toBeUndefined();
127
127
  });
128
128
  it("should overwrite existing values", async () => {
129
129
  const key = getTestKey("overwrite");
130
130
  await cache.set(key, "initial");
131
131
  await cache.set(key, "updated");
132
132
  const result = await cache.get(key);
133
- globalExpect(result).toBe("updated");
133
+ expect(result).toBe("updated");
134
134
  });
135
135
  });
136
136
  describe("delete", () => {
@@ -139,11 +139,11 @@ describe("UpstashCache", () => {
139
139
  await cache.set(key, "value-to-delete");
140
140
  await cache.delete(key);
141
141
  const result = await cache.get(key);
142
- globalExpect(result).toBeUndefined();
142
+ expect(result).toBeUndefined();
143
143
  });
144
144
  it("should handle deletion of non-existent key", async () => {
145
145
  const key = getTestKey("non-existent-delete");
146
- await globalExpect(cache.delete(key)).resolves.not.toThrow();
146
+ await expect(cache.delete(key)).resolves.not.toThrow();
147
147
  });
148
148
  it("should only delete specified key", async () => {
149
149
  const key1 = getTestKey("delete-key1");
@@ -151,8 +151,8 @@ describe("UpstashCache", () => {
151
151
  await cache.set(key1, "value1");
152
152
  await cache.set(key2, "value2");
153
153
  await cache.delete(key1);
154
- globalExpect(await cache.get(key1)).toBeUndefined();
155
- globalExpect(await cache.get(key2)).toBe("value2");
154
+ expect(await cache.get(key1)).toBeUndefined();
155
+ expect(await cache.get(key2)).toBe("value2");
156
156
  });
157
157
  });
158
158
  describe("integration scenarios", () => {
@@ -168,7 +168,7 @@ describe("UpstashCache", () => {
168
168
  };
169
169
  await cache.set(key, testData);
170
170
  const result = await cache.get(key);
171
- globalExpect(result).toEqual(testData);
171
+ expect(result).toEqual(testData);
172
172
  });
173
173
  it("should handle complex nested objects", async () => {
174
174
  const key = getTestKey("complex");
@@ -178,7 +178,7 @@ describe("UpstashCache", () => {
178
178
  } } } };
179
179
  await cache.set(key, complexObject);
180
180
  const result = await cache.get(key);
181
- globalExpect(result).toEqual(complexObject);
181
+ expect(result).toEqual(complexObject);
182
182
  });
183
183
  it("should handle concurrent operations", async () => {
184
184
  const keys = [
@@ -193,7 +193,7 @@ describe("UpstashCache", () => {
193
193
  ];
194
194
  await Promise.all(keys.map((key, i) => cache.set(key, values[i])));
195
195
  const results = await Promise.all(keys.map((key) => cache.get(key)));
196
- globalExpect(results).toEqual(values);
196
+ expect(results).toEqual(values);
197
197
  });
198
198
  });
199
199
  });
@@ -0,0 +1,25 @@
1
+ //#region src/index.d.ts
2
+ interface Cache<T> {
3
+ /**
4
+ * Retrieves a value from the cache.
5
+ *
6
+ * @param key The key to retrieve the value for.
7
+ */
8
+ get(key: string): Promise<T | undefined>;
9
+ /**
10
+ * Sets a value in the cache.
11
+ *
12
+ * @param key The key to set the value for.
13
+ * @param value The value to cache.
14
+ * @param ttl Optional time-to-live in seconds. If not provided, the value will not expire.
15
+ */
16
+ set(key: string, value: T, ttl?: number): Promise<void>;
17
+ /**
18
+ * Deletes a value from the cache.
19
+ *
20
+ * @param key The key to delete from the cache.
21
+ */
22
+ delete(key: string): Promise<void>;
23
+ }
24
+ //#endregion
25
+ export { Cache };
@@ -0,0 +1,25 @@
1
+ //#region src/index.d.ts
2
+ interface Cache<T> {
3
+ /**
4
+ * Retrieves a value from the cache.
5
+ *
6
+ * @param key The key to retrieve the value for.
7
+ */
8
+ get(key: string): Promise<T | undefined>;
9
+ /**
10
+ * Sets a value in the cache.
11
+ *
12
+ * @param key The key to set the value for.
13
+ * @param value The value to cache.
14
+ * @param ttl Optional time-to-live in seconds. If not provided, the value will not expire.
15
+ */
16
+ set(key: string, value: T, ttl?: number): Promise<void>;
17
+ /**
18
+ * Deletes a value from the cache.
19
+ *
20
+ * @param key The key to delete from the cache.
21
+ */
22
+ delete(key: string): Promise<void>;
23
+ }
24
+ //#endregion
25
+ export { Cache };
@@ -0,0 +1,2 @@
1
+ import { Cache } from "./index-q3xYn8_0.cjs";
2
+ export { Cache };
@@ -0,0 +1,2 @@
1
+ import { Cache } from "./index-BPnJ3lrS.mjs";
2
+ export { Cache };
@@ -0,0 +1,11 @@
1
+ import { Cache } from "./index-q3xYn8_0.cjs";
2
+
3
+ //#region src/memory.d.ts
4
+ declare class InMemoryCache<T> implements Cache<T> {
5
+ private store;
6
+ get(key: string): Promise<T | undefined>;
7
+ set(key: string, value: T): Promise<void>;
8
+ delete(key: string): Promise<void>;
9
+ }
10
+ //#endregion
11
+ export { InMemoryCache };
@@ -0,0 +1,11 @@
1
+ import { Cache } from "./index-BPnJ3lrS.mjs";
2
+
3
+ //#region src/memory.d.ts
4
+ declare class InMemoryCache<T> implements Cache<T> {
5
+ private store;
6
+ get(key: string): Promise<T | undefined>;
7
+ set(key: string, value: T): Promise<void>;
8
+ delete(key: string): Promise<void>;
9
+ }
10
+ //#endregion
11
+ export { InMemoryCache };
package/dist/memory.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { InMemoryCache } from "./memory-YteQXj7m.mjs";
1
+ import { InMemoryCache } from "./memory-NQi0XmZ2.mjs";
2
2
 
3
3
  export { InMemoryCache };
@@ -0,0 +1,12 @@
1
+ import { Cache } from "./index-q3xYn8_0.cjs";
2
+
3
+ //#region src/upstash.d.ts
4
+ declare class UpstashCache<T> implements Cache<T> {
5
+ private client;
6
+ constructor(url: string, token: string);
7
+ get(key: string): Promise<T | undefined>;
8
+ set(key: string, value: T, ttl?: number): Promise<void>;
9
+ delete(key: string): Promise<void>;
10
+ }
11
+ //#endregion
12
+ export { UpstashCache };
@@ -0,0 +1,12 @@
1
+ import { Cache } from "./index-BPnJ3lrS.mjs";
2
+
3
+ //#region src/upstash.d.ts
4
+ declare class UpstashCache<T> implements Cache<T> {
5
+ private client;
6
+ constructor(url: string, token: string);
7
+ get(key: string): Promise<T | undefined>;
8
+ set(key: string, value: T, ttl?: number): Promise<void>;
9
+ delete(key: string): Promise<void>;
10
+ }
11
+ //#endregion
12
+ export { UpstashCache };