@blackglory/cache-js 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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/es2015/index.min.mjs +30 -0
  4. package/dist/es2015/index.min.mjs.map +1 -0
  5. package/dist/es2015/index.mjs +27939 -0
  6. package/dist/es2015/index.mjs.map +1 -0
  7. package/dist/es2015/index.umd.js +27951 -0
  8. package/dist/es2015/index.umd.js.map +1 -0
  9. package/dist/es2015/index.umd.min.js +31 -0
  10. package/dist/es2015/index.umd.min.js.map +1 -0
  11. package/dist/es2018/index.min.mjs +16 -0
  12. package/dist/es2018/index.min.mjs.map +1 -0
  13. package/dist/es2018/index.mjs +27888 -0
  14. package/dist/es2018/index.mjs.map +1 -0
  15. package/dist/es2018/index.umd.js +27900 -0
  16. package/dist/es2018/index.umd.js.map +1 -0
  17. package/dist/es2018/index.umd.min.js +16 -0
  18. package/dist/es2018/index.umd.min.js.map +1 -0
  19. package/lib/es2015/cache.d.ts +36 -0
  20. package/lib/es2015/cache.js +113 -0
  21. package/lib/es2015/cache.js.map +1 -0
  22. package/lib/es2015/contract.d.ts +23 -0
  23. package/lib/es2015/contract.js +3 -0
  24. package/lib/es2015/contract.js.map +1 -0
  25. package/lib/es2015/index.d.ts +1 -0
  26. package/lib/es2015/index.js +18 -0
  27. package/lib/es2015/index.js.map +1 -0
  28. package/lib/es2015/rpc-client.browser.d.ts +8 -0
  29. package/lib/es2015/rpc-client.browser.js +35 -0
  30. package/lib/es2015/rpc-client.browser.js.map +1 -0
  31. package/lib/es2015/rpc-client.d.ts +8 -0
  32. package/lib/es2015/rpc-client.js +36 -0
  33. package/lib/es2015/rpc-client.js.map +1 -0
  34. package/lib/es2018/cache.d.ts +36 -0
  35. package/lib/es2018/cache.js +80 -0
  36. package/lib/es2018/cache.js.map +1 -0
  37. package/lib/es2018/contract.d.ts +23 -0
  38. package/lib/es2018/contract.js +3 -0
  39. package/lib/es2018/contract.js.map +1 -0
  40. package/lib/es2018/index.d.ts +1 -0
  41. package/lib/es2018/index.js +18 -0
  42. package/lib/es2018/index.js.map +1 -0
  43. package/lib/es2018/rpc-client.browser.d.ts +8 -0
  44. package/lib/es2018/rpc-client.browser.js +24 -0
  45. package/lib/es2018/rpc-client.browser.js.map +1 -0
  46. package/lib/es2018/rpc-client.d.ts +8 -0
  47. package/lib/es2018/rpc-client.js +25 -0
  48. package/lib/es2018/rpc-client.js.map +1 -0
  49. package/package.json +77 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 BlackGlory <woshenmedoubuzhidao@blackglory.me>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # cache-js
2
+ ## Install
3
+ ```sh
4
+ npm install --save @blackglory/cache-js
5
+ # or
6
+ yarn add @blackglory/cache-js
7
+ ```
8
+
9
+ ## API
10
+ ### CacheClient
11
+ ```ts
12
+ interface IMetadata {
13
+ updatedAt: number
14
+ timeToLive: number
15
+ timeBeforeDeletion: number
16
+ }
17
+
18
+ interface ICacheClientOptions {
19
+ server: string
20
+ timeout?: number
21
+ }
22
+
23
+ class CacheClient {
24
+ static create(options: ICacheClientOptions): Promise<CacheClient>
25
+
26
+ close(): void
27
+ has(namespace: string, key: string, timeout?: number): Promise<boolean>
28
+ get(namespace: string, key: string, timeout?: number): Promise<string | null>
29
+ bulkGet(
30
+ namespace: string
31
+ , keys: string[]
32
+ , timeout?: number
33
+ ): Promise<Array<string | null>>
34
+ getWithMetadata(namespace: string, key: string, timeout?: number): Promise<{
35
+ value: string
36
+ metadata: IMetadata
37
+ } | null>
38
+ set(
39
+ namespace: string
40
+ , key: string
41
+ , value: string
42
+ , timeToLive: number
43
+ , timeBeforeDeletion: number
44
+ , timeout?: number
45
+ ): Promise<void>
46
+ del(namespace: string, key: string, timeout?: number): Promise<void>
47
+ clear(namespace: string, timeout?: number): Promise<void>
48
+ getAllItemKeys(namespace: string, timeout?: number): Promise<string[]>
49
+ getAllNamespaces(timeout?: number): Promise<string[]>
50
+ stats(namespace: string, timeout?: number): Promise<IStats>
51
+ }
52
+ ```