@aws-amplify/cache 4.0.51-next.20 → 4.0.51-next.32

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 (52) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/BrowserStorageCache.js +0 -4
  4. package/lib/BrowserStorageCache.js.map +1 -1
  5. package/lib/InMemoryCache.js +0 -4
  6. package/lib/InMemoryCache.js.map +1 -1
  7. package/lib/StorageCache.js +0 -4
  8. package/lib/StorageCache.js.map +1 -1
  9. package/lib/index.js +0 -4
  10. package/lib/index.js.map +1 -1
  11. package/lib/reactnative.js +0 -4
  12. package/lib/reactnative.js.map +1 -1
  13. package/lib-esm/.tsbuildinfo +3 -0
  14. package/lib-esm/BrowserStorageCache.d.ts +0 -4
  15. package/lib-esm/BrowserStorageCache.js +0 -4
  16. package/lib-esm/BrowserStorageCache.js.map +1 -1
  17. package/lib-esm/InMemoryCache.d.ts +0 -4
  18. package/lib-esm/InMemoryCache.js +0 -4
  19. package/lib-esm/InMemoryCache.js.map +1 -1
  20. package/lib-esm/StorageCache.d.ts +0 -4
  21. package/lib-esm/StorageCache.js +0 -4
  22. package/lib-esm/StorageCache.js.map +1 -1
  23. package/lib-esm/index.d.ts +0 -4
  24. package/lib-esm/index.js +0 -4
  25. package/lib-esm/index.js.map +1 -1
  26. package/lib-esm/reactnative.d.ts +0 -4
  27. package/lib-esm/reactnative.js +0 -4
  28. package/lib-esm/reactnative.js.map +1 -1
  29. package/package.json +8 -3
  30. package/src/BrowserStorageCache.ts +0 -5
  31. package/src/InMemoryCache.ts +0 -4
  32. package/src/StorageCache.ts +0 -5
  33. package/src/index.ts +0 -4
  34. package/src/reactnative.ts +0 -4
  35. package/build.js +0 -5
  36. package/dist/aws-amplify-cache.js +0 -1699
  37. package/dist/aws-amplify-cache.js.map +0 -1
  38. package/dist/aws-amplify-cache.min.js +0 -2
  39. package/dist/aws-amplify-cache.min.js.map +0 -1
  40. package/index.js +0 -7
  41. package/lib/AsyncStorageCache.d.ts +0 -155
  42. package/lib/BrowserStorageCache.d.ts +0 -169
  43. package/lib/InMemoryCache.d.ts +0 -135
  44. package/lib/StorageCache.d.ts +0 -35
  45. package/lib/Utils/CacheList.d.ts +0 -89
  46. package/lib/Utils/CacheUtils.d.ts +0 -24
  47. package/lib/Utils/index.d.ts +0 -2
  48. package/lib/index.d.ts +0 -8
  49. package/lib/reactnative.d.ts +0 -6
  50. package/lib/types/Cache.d.ts +0 -55
  51. package/lib/types/index.d.ts +0 -1
  52. package/webpack.config.dev.js +0 -6
@@ -1,135 +0,0 @@
1
- import { StorageCache } from './StorageCache';
2
- import { ICache, CacheConfig, CacheItemOptions } from './types';
3
- /**
4
- * Customized in-memory cache with LRU implemented
5
- * @member cacheObj - object which store items
6
- * @member cacheList - list of keys in the cache with LRU
7
- * @member curSizeInBytes - current size of the cache
8
- * @member maxPriority - max of the priority
9
- * @member cacheSizeLimit - the limit of cache size
10
- */
11
- export declare class InMemoryCacheClass extends StorageCache implements ICache {
12
- private cacheList;
13
- private curSizeInBytes;
14
- private maxPriority;
15
- private cacheSizeLimit;
16
- /**
17
- * initialize the cache
18
- *
19
- * @param config - the configuration of the cache
20
- */
21
- constructor(config?: CacheConfig);
22
- /**
23
- * decrease current size of the cache
24
- *
25
- * @param amount - the amount of the cache size which needs to be decreased
26
- */
27
- private _decreaseCurSizeInBytes;
28
- /**
29
- * increase current size of the cache
30
- *
31
- * @param amount - the amount of the cache szie which need to be increased
32
- */
33
- private _increaseCurSizeInBytes;
34
- /**
35
- * check whether item is expired
36
- *
37
- * @param key - the key of the item
38
- *
39
- * @return true if the item is expired.
40
- */
41
- private _isExpired;
42
- /**
43
- * delete item from cache
44
- *
45
- * @param prefixedKey - the key of the item
46
- * @param listIdx - indicates which cache list the key belongs to
47
- */
48
- private _removeItem;
49
- /**
50
- * put item into cache
51
- *
52
- * @param prefixedKey - the key of the item
53
- * @param itemData - the value of the item
54
- * @param itemSizeInBytes - the byte size of the item
55
- * @param listIdx - indicates which cache list the key belongs to
56
- */
57
- private _setItem;
58
- /**
59
- * see whether cache is full
60
- *
61
- * @param itemSize
62
- *
63
- * @return true if cache is full
64
- */
65
- private _isCacheFull;
66
- /**
67
- * check whether the cache contains the key
68
- *
69
- * @param key
70
- */
71
- private containsKey;
72
- /**
73
- * * Set item into cache. You can put number, string, boolean or object.
74
- * The cache will first check whether has the same key.
75
- * If it has, it will delete the old item and then put the new item in
76
- * The cache will pop out items if it is full
77
- * You can specify the cache item options. The cache will abort and output a warning:
78
- * If the key is invalid
79
- * If the size of the item exceeds itemMaxSize.
80
- * If the value is undefined
81
- * If incorrect cache item configuration
82
- * If error happened with browser storage
83
- *
84
- * @param key - the key of the item
85
- * @param value - the value of the item
86
- * @param options - optional, the specified meta-data
87
- *
88
- * @throws if the item is too big which exceeds the limit of single item size
89
- * @throws if the key is invalid
90
- */
91
- setItem(key: string, value: object | string | number | boolean, options?: CacheItemOptions): void;
92
- /**
93
- * Get item from cache. It will return null if item doesn’t exist or it has been expired.
94
- * If you specified callback function in the options,
95
- * then the function will be executed if no such item in the cache
96
- * and finally put the return value into cache.
97
- * Please make sure the callback function will return the value you want to put into the cache.
98
- * The cache will abort output a warning:
99
- * If the key is invalid
100
- *
101
- * @param key - the key of the item
102
- * @param options - the options of callback function
103
- */
104
- getItem(key: string, options?: CacheItemOptions): any;
105
- /**
106
- * remove item from the cache
107
- *
108
- * @param key - the key of the item
109
- */
110
- removeItem(key: string): void;
111
- /**
112
- * clear the entire cache
113
- */
114
- clear(): void;
115
- /**
116
- * Return all the keys in the cache.
117
- */
118
- getAllKeys(): string[];
119
- /**
120
- * return the current size of the cache
121
- *
122
- * @return the current size of the cache
123
- */
124
- getCacheCurSize(): number;
125
- /**
126
- * Return a new instance of cache with customized configuration.
127
- * @param config - the customized configuration
128
- */
129
- createInstance(config: CacheConfig): ICache;
130
- }
131
- export declare const InMemoryCache: ICache;
132
- /**
133
- * @deprecated use named import
134
- */
135
- export default InMemoryCache;
@@ -1,35 +0,0 @@
1
- import { CacheConfig, CacheItem, CacheItemOptions } from './types';
2
- /**
3
- * Initialization of the cache
4
- *
5
- */
6
- export declare class StorageCache {
7
- protected cacheCurSizeKey: string;
8
- protected config: CacheConfig;
9
- /**
10
- * Initialize the cache
11
- * @param config - the configuration of the cache
12
- */
13
- constructor(config: CacheConfig);
14
- getModuleName(): string;
15
- private checkConfig;
16
- /**
17
- * produce a JSON object with meta-data and data value
18
- * @param value - the value of the item
19
- * @param options - optional, the specified meta-data
20
- *
21
- * @return - the item which has the meta-data and the value
22
- */
23
- protected fillCacheItem(key: string, value: object | number | string | boolean, options: CacheItemOptions): CacheItem;
24
- /**
25
- * set cache with customized configuration
26
- * @param config - customized configuration
27
- *
28
- * @return - the current configuration
29
- */
30
- configure(config?: CacheConfig): CacheConfig;
31
- }
32
- /**
33
- * @deprecated use named import
34
- */
35
- export default StorageCache;
@@ -1,89 +0,0 @@
1
- /**
2
- * double linked list plus a hash table inside
3
- * each key in the cache stored as a node in the list
4
- * recently visited node will be rotated to the head
5
- * so the Last Recently Visited node will be at the tail
6
- *
7
- * @member head - dummy head of the linked list
8
- * @member tail - dummy tail of the linked list
9
- * @member hashtable - the hashtable which maps cache key to list node
10
- * @member length - length of the list
11
- */
12
- export default class CacheList {
13
- private head;
14
- private tail;
15
- private hashtable;
16
- private length;
17
- /**
18
- * initialization
19
- */
20
- constructor();
21
- /**
22
- * insert node to the head of the list
23
- *
24
- * @param node
25
- */
26
- private insertNodeToHead;
27
- /**
28
- * remove node
29
- *
30
- * @param node
31
- */
32
- private removeNode;
33
- /**
34
- * @return true if list is empty
35
- */
36
- isEmpty(): boolean;
37
- /**
38
- * refresh node so it is rotated to the head
39
- *
40
- * @param key - key of the node
41
- */
42
- refresh(key: string): void;
43
- /**
44
- * insert new node to the head and add it in the hashtable
45
- *
46
- * @param key - the key of the node
47
- */
48
- insertItem(key: string): void;
49
- /**
50
- * @return the LAST Recently Visited key
51
- */
52
- getLastItem(): string;
53
- /**
54
- * remove the cache key from the list and hashtable
55
- * @param key - the key of the node
56
- */
57
- removeItem(key: string): void;
58
- /**
59
- * @return length of the list
60
- */
61
- getSize(): number;
62
- /**
63
- * @return true if the key is in the hashtable
64
- * @param key
65
- */
66
- containsKey(key: string): boolean;
67
- /**
68
- * clean up the list and hashtable
69
- */
70
- clearList(): void;
71
- /**
72
- * @return all keys in the hashtable
73
- */
74
- getKeys(): string[];
75
- /**
76
- * mainly for test
77
- *
78
- * @param key
79
- * @return true if key is the head node
80
- */
81
- isHeadNode(key: string): boolean;
82
- /**
83
- * mainly for test
84
- *
85
- * @param key
86
- * @return true if key is the tail node
87
- */
88
- isTailNode(key: string): boolean;
89
- }
@@ -1,24 +0,0 @@
1
- import { CacheConfig } from '../types';
2
- /**
3
- * Default cache config
4
- */
5
- export declare const defaultConfig: CacheConfig;
6
- /**
7
- * return the byte size of the string
8
- * @param str
9
- */
10
- export declare function getByteLength(str: string): number;
11
- /**
12
- * get current time
13
- */
14
- export declare function getCurrTime(): number;
15
- /**
16
- * check if passed value is an integer
17
- */
18
- export declare function isInteger(value: any): boolean;
19
- export declare class CacheObject {
20
- static clear(): void;
21
- static getItem(key: string): string | null;
22
- static setItem(key: string, value: string): void;
23
- static removeItem(key: string): void;
24
- }
@@ -1,2 +0,0 @@
1
- export * from './CacheUtils';
2
- export { default as CacheList } from './CacheList';
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { BrowserStorageCache } from './BrowserStorageCache';
2
- import { InMemoryCache } from './InMemoryCache';
3
- import { CacheConfig } from './types';
4
- export { BrowserStorageCache, InMemoryCache, CacheConfig };
5
- /**
6
- * @deprecated use named import
7
- */
8
- export default BrowserStorageCache;
@@ -1,6 +0,0 @@
1
- import { Cache, AsyncStorageCache } from './AsyncStorageCache';
2
- export { Cache, AsyncStorageCache };
3
- /**
4
- * @deprecated use named import
5
- */
6
- export default Cache;
@@ -1,55 +0,0 @@
1
- /**
2
- * Cache Interface
3
- */
4
- export interface ICache {
5
- /** Put item into cache */
6
- setItem(key: string, value: any, options?: CacheItemOptions): void;
7
- /** Get item from cache */
8
- getItem(key: string, options?: CacheItemOptions): any;
9
- /** Remove item from cache */
10
- removeItem(key: string): void;
11
- /** Remove all items from cache */
12
- clear(): void;
13
- /** Get all keys form cache */
14
- getAllKeys(): string[] | Promise<string[]>;
15
- /** Get current size of the cache */
16
- getCacheCurSize(): number | Promise<number>;
17
- /** create a new instance with customized config */
18
- createInstance(config: CacheConfig): ICache;
19
- /** change current configuration */
20
- configure(config: CacheConfig): CacheConfig;
21
- }
22
- /**
23
- * Cache instance options
24
- */
25
- export interface CacheConfig {
26
- /** Prepend to key to avoid conflicts */
27
- keyPrefix?: string;
28
- /** Cache capacity, in bytes */
29
- capacityInBytes?: number;
30
- /** Max size of one item */
31
- itemMaxSize?: number;
32
- /** Time to live, in milliseconds */
33
- defaultTTL?: number;
34
- /** Warn when over threshold percentage of capacity, maximum 1 */
35
- warningThreshold?: number;
36
- /** default priority number put on cached items */
37
- defaultPriority?: number;
38
- storage?: Storage;
39
- Cache?: Cache;
40
- }
41
- export interface CacheItem {
42
- key: string;
43
- data: any;
44
- timestamp: number;
45
- visitedTime: number;
46
- priority: number;
47
- expires: number;
48
- type: string;
49
- byteSize: number;
50
- }
51
- export interface CacheItemOptions {
52
- priority?: number;
53
- expires?: number;
54
- callback?: Function;
55
- }
@@ -1 +0,0 @@
1
- export * from './Cache';
@@ -1,6 +0,0 @@
1
- var config = require('./webpack.config.js');
2
-
3
- var entry = {
4
- 'aws-amplify-cache': './lib-esm/index.js',
5
- };
6
- module.exports = Object.assign(config, { entry, mode: 'development' });