@blackglory/cache-js 0.8.1 → 0.9.1

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 CHANGED
@@ -23,31 +23,37 @@ interface ICacheClientOptions {
23
23
  class CacheClient {
24
24
  static create(options: ICacheClientOptions): Promise<CacheClient>
25
25
 
26
- set(
27
- namespace: string
28
- , key: string
29
- , value: string
30
- , timeToLive: number | null
31
- , timeout?: number
32
- ): Promise<void>
26
+ close(): Promise<void>
27
+
28
+ stats(namespace: string, timeout?: number): Promise<IStats>
29
+ getAllNamespaces(timeout?: number): Promise<string[]>
30
+ getAllItemKeys(namespace: string, timeout?: number): Promise<string[]>
31
+
32
+ hasItem(namespace: string, itemKey: string, timeout?: number): Promise<boolean>
33
33
 
34
- has(namespace: string, key: string, timeout?: number): Promise<boolean>
34
+ getItem(namespace: string, itemKey: string, timeout?: number): Promise<string | null>
35
35
 
36
- get(namespace: string, key: string, timeout?: number): Promise<string | null>
37
- bulkGet(
36
+ getItemWithMetadata(namespace: string, itemKey: string, timeout?: number): Promise<{
37
+ value: string
38
+ metadata: IMetadata
39
+ } | null>
40
+
41
+ getItems(
38
42
  namespace: string
39
- , keys: string[]
43
+ , itemKeys: string[]
40
44
  , timeout?: number
41
45
  ): Promise<Array<string | null>>
42
46
 
43
- del(namespace: string, key: string, timeout?: number): Promise<void>
44
- clear(namespace: string, timeout?: number): Promise<void>
45
-
46
- getAllItemKeys(namespace: string, timeout?: number): Promise<string[]>
47
- getAllNamespaces(timeout?: number): Promise<string[]>
47
+ setItem(
48
+ namespace: string
49
+ , itemKey: string
50
+ , itemValue: string
51
+ , timeToLive: number | null
52
+ , timeout?: number
53
+ ): Promise<void>
48
54
 
49
- stats(namespace: string, timeout?: number): Promise<IStats>
55
+ removeItem(namespace: string, itemKey: string, timeout?: number): Promise<void>
50
56
 
51
- close(): Promise<void>
57
+ clearItemsByNamespace(namespace: string, timeout?: number): Promise<void>
52
58
  }
53
59
  ```
package/lib/cache.d.ts CHANGED
@@ -15,21 +15,21 @@ export declare class CacheClient {
15
15
  private batchProxy;
16
16
  private closeClients;
17
17
  private timeout?;
18
+ stats(namespace: string, timeout?: number): Promise<IStats>;
19
+ getAllNamespaces(timeout?: number): Promise<string[]>;
20
+ getAllItemKeys(namespace: string, timeout?: number): Promise<string[]>;
18
21
  private constructor();
19
22
  static create(options: ICacheClientOptions): Promise<CacheClient>;
20
23
  close(): Promise<void>;
21
- has(namespace: string, key: string, timeout?: number): Promise<boolean>;
22
- get(namespace: string, key: string, timeout?: number): Promise<string | null>;
23
- getWithMetadata(namespace: string, key: string, timeout?: number): Promise<{
24
+ hasItem(namespace: string, itemKey: string, timeout?: number): Promise<boolean>;
25
+ getItem(namespace: string, itemKey: string, timeout?: number): Promise<string | null>;
26
+ getItemWithMetadata(namespace: string, itemKey: string, timeout?: number): Promise<{
24
27
  value: string;
25
28
  metadata: IMetadata;
26
29
  } | null>;
27
- bulkGet(namespace: string, keys: string[], timeout?: number): Promise<Array<string | null>>;
28
- set(namespace: string, key: string, value: string, timeToLive: number | null, timeout?: number): Promise<void>;
29
- del(namespace: string, key: string, timeout?: number): Promise<void>;
30
- clear(namespace: string, timeout?: number): Promise<void>;
31
- getAllItemKeys(namespace: string, timeout?: number): Promise<string[]>;
32
- getAllNamespaces(timeout?: number): Promise<string[]>;
33
- stats(namespace: string, timeout?: number): Promise<IStats>;
30
+ getItems(namespace: string, itemKeys: string[], timeout?: number): Promise<Array<string | null>>;
31
+ setItem(namespace: string, itemKey: string, itemValue: string, timeToLive: number | null, timeout?: number): Promise<void>;
32
+ removeItem(namespace: string, itemKey: string, timeout?: number): Promise<void>;
33
+ clearItemsByNamespace(namespace: string, timeout?: number): Promise<void>;
34
34
  private withTimeout;
35
35
  }
package/lib/cache.js CHANGED
@@ -9,6 +9,15 @@ export class CacheClient {
9
9
  this.closeClients = closeClients;
10
10
  this.timeout = timeout;
11
11
  }
12
+ async stats(namespace, timeout) {
13
+ return await this.withTimeout(() => this.client.stats(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
14
+ }
15
+ async getAllNamespaces(timeout) {
16
+ return await this.withTimeout(() => this.client.getAllNamespaces(), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
17
+ }
18
+ async getAllItemKeys(namespace, timeout) {
19
+ return await this.withTimeout(() => this.client.getAllItemKeys(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
20
+ }
12
21
  static async create(options) {
13
22
  const { client, batchClient, proxy, close } = await createRPCClient(options.server);
14
23
  return new CacheClient(client, batchClient, proxy, close, options.timeout);
@@ -16,15 +25,15 @@ export class CacheClient {
16
25
  async close() {
17
26
  await this.closeClients();
18
27
  }
19
- async has(namespace, key, timeout) {
20
- return await this.withTimeout(() => this.client.has(namespace, key), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
28
+ async hasItem(namespace, itemKey, timeout) {
29
+ return await this.withTimeout(() => this.client.hasItem(namespace, itemKey), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
21
30
  }
22
- async get(namespace, key, timeout) {
23
- return await this.withTimeout(() => this.client.get(namespace, key), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
31
+ async getItem(namespace, itemKey, timeout) {
32
+ return await this.withTimeout(() => this.client.getItem(namespace, itemKey), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
24
33
  }
25
- async getWithMetadata(namespace, key, timeout) {
34
+ async getItemWithMetadata(namespace, itemKey, timeout) {
26
35
  return await this.withTimeout(async () => {
27
- const result = await this.client.getWithMetadata(namespace, key);
36
+ const result = await this.client.getItemWithMetadata(namespace, itemKey);
28
37
  if (isNull(result))
29
38
  return null;
30
39
  return {
@@ -36,29 +45,20 @@ export class CacheClient {
36
45
  };
37
46
  }, timeout !== null && timeout !== void 0 ? timeout : this.timeout);
38
47
  }
39
- async bulkGet(namespace, keys, timeout) {
48
+ async getItems(namespace, itemKeys, timeout) {
40
49
  return await this.withTimeout(async () => {
41
- const results = await this.batchClient.parallel(...keys.map(key => this.batchProxy.get(namespace, key)));
50
+ const results = await this.batchClient.parallel(...itemKeys.map(key => this.batchProxy.getItem(namespace, key)));
42
51
  return results.map(result => result.unwrap());
43
52
  }, timeout !== null && timeout !== void 0 ? timeout : this.timeout);
44
53
  }
45
- async set(namespace, key, value, timeToLive, timeout) {
46
- await this.withTimeout(() => this.client.set(namespace, key, value, timeToLive), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
54
+ async setItem(namespace, itemKey, itemValue, timeToLive, timeout) {
55
+ await this.withTimeout(() => this.client.setItem(namespace, itemKey, itemValue, timeToLive), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
47
56
  }
48
- async del(namespace, key, timeout) {
49
- await this.withTimeout(() => this.client.del(namespace, key), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
57
+ async removeItem(namespace, itemKey, timeout) {
58
+ await this.withTimeout(() => this.client.removeItem(namespace, itemKey), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
50
59
  }
51
- async clear(namespace, timeout) {
52
- await this.withTimeout(() => this.client.clear(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
53
- }
54
- async getAllItemKeys(namespace, timeout) {
55
- return await this.withTimeout(() => this.client.getAllItemKeys(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
56
- }
57
- async getAllNamespaces(timeout) {
58
- return await this.withTimeout(() => this.client.getAllNamespaces(), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
59
- }
60
- async stats(namespace, timeout) {
61
- return await this.withTimeout(() => this.client.stats(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
60
+ async clearItemsByNamespace(namespace, timeout) {
61
+ await this.withTimeout(() => this.client.clearItemsByNamespace(namespace), timeout !== null && timeout !== void 0 ? timeout : this.timeout);
62
62
  }
63
63
  async withTimeout(fn, timeout = this.timeout) {
64
64
  if (timeout) {
package/lib/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":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,OAAe,EACf,SAAiB,EACjB,UAAyB,EACzB,OAAgB;QAEhB,MAAM,IAAI,CAAC,WAAW,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,SAAS,EACT,OAAO,EACP,SAAS,EACT,UAAU,CACX,EACD,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,OAAO,CACxB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,SAAiB,EAAE,OAAe,EAAE,OAAgB;QACnE,MAAM,IAAI,CAAC,WAAW,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,EAChD,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,OAAO,CACxB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,SAAiB,EAAE,OAAgB;QAC7D,MAAM,IAAI,CAAC,WAAW,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAClD,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,OAAO,CACxB,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,EAAwB,EACxB,UAA8B,IAAI,CAAC,OAAO;QAE1C,IAAI,OAAO,EAAE;YACX,OAAO,MAAM,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;SACzD;aAAM;YACL,OAAO,MAAM,EAAE,EAAE,CAAA;SAClB;IACH,CAAC;CACF"}
package/lib/contract.d.ts CHANGED
@@ -1,17 +1,4 @@
1
- export interface IAPI {
2
- has(namespace: string, key: string): Promise<boolean>;
3
- get(namespace: string, key: string): Promise<string | null>;
4
- getWithMetadata(namespace: string, key: string): Promise<{
5
- value: string;
6
- metadata: IMetadata;
7
- } | null>;
8
- set(namespace: string, key: string, value: string, timeToLive: number | null): Promise<null>;
9
- del(namespace: string, key: string): Promise<null>;
10
- clear(namespace: string): Promise<null>;
11
- getAllItemKeys(namespace: string): Promise<string[]>;
12
- getAllNamespaces(): Promise<string[]>;
13
- stats(namespace: string): Promise<IStats>;
14
- }
1
+ export declare const expectedVersion = "^0.8.0";
15
2
  export interface IStats {
16
3
  namespace: string;
17
4
  items: number;
@@ -20,4 +7,17 @@ export interface IMetadata {
20
7
  updatedAt: number;
21
8
  timeToLive: number | null;
22
9
  }
23
- export declare const expectedVersion = "^0.6.0 || ^0.7.0";
10
+ export interface IAPI {
11
+ stats(namespace: string): IStats;
12
+ getAllNamespaces(): string[];
13
+ getAllItemKeys(namespace: string): string[];
14
+ hasItem(namespace: string, itemKey: string): boolean;
15
+ getItem(namespace: string, itemKey: string): string | null;
16
+ getItemWithMetadata(namespace: string, itemKey: string): {
17
+ value: string;
18
+ metadata: IMetadata;
19
+ } | null;
20
+ setItem(namespace: string, itemKey: string, itemValue: string, timeToLive: number | null): null;
21
+ removeItem(namespace: string, itemKey: string): null;
22
+ clearItemsByNamespace(namespace: string): null;
23
+ }
package/lib/contract.js CHANGED
@@ -1,2 +1,2 @@
1
- export const expectedVersion = '^0.6.0 || ^0.7.0';
1
+ export const expectedVersion = '^0.8.0';
2
2
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AA+BA,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAA"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackglory/cache-js",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [