@graphql-mesh/cache-upstash-redis 0.0.1-alpha-20250211122104-7cfcce753fcf508db367836e97e66dc239790be3 → 0.0.1-alpha-20250211124921-80b7ea5df06762575f40c0b639cebef137c13408

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/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
4
+ const utils_1 = require("@graphql-mesh/utils");
4
5
  const redis_1 = require("@upstash/redis");
5
6
  const disposablestack_1 = require("@whatwg-node/disposablestack");
6
7
  class UpstashRedisCache {
@@ -18,19 +19,18 @@ class UpstashRedisCache {
18
19
  get(key) {
19
20
  return this.redis.get(key);
20
21
  }
21
- async set(key, value, options) {
22
+ set(key, value, options) {
22
23
  if (options?.ttl) {
23
- await this.redis.set(key, value, {
24
+ return this.redis.set(key, value, {
24
25
  px: options.ttl * 1000,
25
26
  });
26
27
  }
27
28
  else {
28
- await this.redis.set(key, value);
29
+ return this.redis.set(key, value);
29
30
  }
30
31
  }
31
- async delete(key) {
32
- const num = await this.redis.del(key);
33
- return num > 0;
32
+ delete(key) {
33
+ return (0, utils_1.mapMaybePromise)(this.redis.del(key), num => num > 0);
34
34
  }
35
35
  async getKeysByPrefix(prefix) {
36
36
  const keys = [];
package/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { process } from '@graphql-mesh/cross-helpers';
2
+ import { mapMaybePromise } from '@graphql-mesh/utils';
2
3
  import { Redis } from '@upstash/redis';
3
4
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
4
5
  export default class UpstashRedisCache {
@@ -16,19 +17,18 @@ export default class UpstashRedisCache {
16
17
  get(key) {
17
18
  return this.redis.get(key);
18
19
  }
19
- async set(key, value, options) {
20
+ set(key, value, options) {
20
21
  if (options?.ttl) {
21
- await this.redis.set(key, value, {
22
+ return this.redis.set(key, value, {
22
23
  px: options.ttl * 1000,
23
24
  });
24
25
  }
25
26
  else {
26
- await this.redis.set(key, value);
27
+ return this.redis.set(key, value);
27
28
  }
28
29
  }
29
- async delete(key) {
30
- const num = await this.redis.del(key);
31
- return num > 0;
30
+ delete(key) {
31
+ return mapMaybePromise(this.redis.del(key), num => num > 0);
32
32
  }
33
33
  async getKeysByPrefix(prefix) {
34
34
  const keys = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/cache-upstash-redis",
3
- "version": "0.0.1-alpha-20250211122104-7cfcce753fcf508db367836e97e66dc239790be3",
3
+ "version": "0.0.1-alpha-20250211124921-80b7ea5df06762575f40c0b639cebef137c13408",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -8,6 +8,7 @@
8
8
  "dependencies": {
9
9
  "@graphql-mesh/cross-helpers": "^0.4.9",
10
10
  "@graphql-mesh/types": "^0.103.12",
11
+ "@graphql-mesh/utils": "^0.103.13",
11
12
  "@upstash/redis": "^1.34.3",
12
13
  "@whatwg-node/disposablestack": "^0.0.5",
13
14
  "tslib": "^2.4.0"
@@ -8,8 +8,8 @@ export default class UpstashRedisCache implements KeyValueCache {
8
8
  get<T>(key: string): Promise<T>;
9
9
  set<T>(key: string, value: T, options?: {
10
10
  ttl?: number;
11
- }): Promise<void>;
12
- delete(key: string): Promise<boolean>;
11
+ }): Promise<"OK" | T>;
12
+ delete(key: string): import("@graphql-mesh/utils").MaybePromise<boolean>;
13
13
  getKeysByPrefix(prefix: string): Promise<string[]>;
14
14
  [DisposableSymbols.dispose](): void;
15
15
  }
@@ -8,8 +8,8 @@ export default class UpstashRedisCache implements KeyValueCache {
8
8
  get<T>(key: string): Promise<T>;
9
9
  set<T>(key: string, value: T, options?: {
10
10
  ttl?: number;
11
- }): Promise<void>;
12
- delete(key: string): Promise<boolean>;
11
+ }): Promise<"OK" | T>;
12
+ delete(key: string): import("@graphql-mesh/utils").MaybePromise<boolean>;
13
13
  getKeysByPrefix(prefix: string): Promise<string[]>;
14
14
  [DisposableSymbols.dispose](): void;
15
15
  }