@aws-amplify/cache 4.0.64-unstable.4 → 4.0.64
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/CHANGELOG.md +19 -0
- package/build.js +5 -0
- package/dist/aws-amplify-cache.js +1484 -0
- package/dist/aws-amplify-cache.js.map +1 -0
- package/dist/aws-amplify-cache.min.js +2 -0
- package/dist/aws-amplify-cache.min.js.map +1 -0
- package/index.js +7 -0
- package/lib/AsyncStorageCache.js +101 -40
- package/lib/AsyncStorageCache.js.map +1 -1
- package/lib/BrowserStorageCache.js +31 -6
- package/lib/BrowserStorageCache.js.map +1 -1
- package/lib/InMemoryCache.js +43 -6
- package/lib/InMemoryCache.js.map +1 -1
- package/lib/StorageCache.js +16 -2
- package/lib/StorageCache.js.map +1 -1
- package/lib/Utils/CacheList.js +24 -4
- package/lib/Utils/CacheList.js.map +1 -1
- package/lib/Utils/CacheUtils.js +12 -2
- package/lib/Utils/CacheUtils.js.map +1 -1
- package/lib/Utils/index.js +16 -8
- package/lib/Utils/index.js.map +1 -1
- package/lib/index.js +18 -2
- package/lib/index.js.map +1 -1
- package/lib/reactnative.js +18 -2
- package/lib/reactnative.js.map +1 -1
- package/lib/types/Cache.js +12 -2
- package/lib/types/Cache.js.map +1 -1
- package/lib/types/index.js +12 -2
- package/lib/types/index.js.map +1 -1
- package/lib-esm/AsyncStorageCache.d.ts +2 -1
- package/lib-esm/AsyncStorageCache.js +64 -6
- package/lib-esm/AsyncStorageCache.js.map +1 -1
- package/lib-esm/BrowserStorageCache.d.ts +4 -0
- package/lib-esm/BrowserStorageCache.js +30 -5
- package/lib-esm/BrowserStorageCache.js.map +1 -1
- package/lib-esm/InMemoryCache.d.ts +4 -0
- package/lib-esm/InMemoryCache.js +40 -3
- package/lib-esm/InMemoryCache.js.map +1 -1
- package/lib-esm/StorageCache.d.ts +4 -0
- package/lib-esm/StorageCache.js +16 -2
- package/lib-esm/StorageCache.js.map +1 -1
- package/lib-esm/Utils/CacheList.js +23 -3
- package/lib-esm/Utils/CacheList.js.map +1 -1
- package/lib-esm/Utils/CacheUtils.js +12 -2
- package/lib-esm/Utils/CacheUtils.js.map +1 -1
- package/lib-esm/Utils/index.d.ts +1 -1
- package/lib-esm/Utils/index.js +13 -3
- package/lib-esm/Utils/index.js.map +1 -1
- package/lib-esm/index.d.ts +4 -0
- package/lib-esm/index.js +18 -3
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/reactnative.d.ts +5 -2
- package/lib-esm/reactnative.js +19 -5
- package/lib-esm/reactnative.js.map +1 -1
- package/lib-esm/types/Cache.js +12 -2
- package/lib-esm/types/Cache.js.map +1 -1
- package/lib-esm/types/index.js +12 -2
- package/lib-esm/types/index.js.map +1 -1
- package/package.json +12 -15
- package/src/AsyncStorageCache.ts +15 -6
- package/src/BrowserStorageCache.ts +18 -4
- package/src/InMemoryCache.ts +16 -2
- package/src/StorageCache.ts +17 -2
- package/src/Utils/CacheList.ts +12 -2
- package/src/Utils/CacheUtils.ts +12 -2
- package/src/Utils/index.ts +15 -11
- package/src/index.ts +20 -4
- package/src/reactnative.ts +19 -5
- package/src/types/Cache.ts +12 -2
- package/src/types/index.ts +12 -2
- package/webpack.config.dev.js +6 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/AsyncStorageCache.d.ts +0 -154
- package/lib/BrowserStorageCache.d.ts +0 -165
- package/lib/InMemoryCache.d.ts +0 -131
- package/lib/StorageCache.d.ts +0 -31
- package/lib/Utils/CacheList.d.ts +0 -89
- package/lib/Utils/CacheUtils.d.ts +0 -24
- package/lib/Utils/index.d.ts +0 -2
- package/lib/index.d.ts +0 -5
- package/lib/reactnative.d.ts +0 -3
- package/lib/types/Cache.d.ts +0 -55
- package/lib/types/index.d.ts +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
package/lib/Utils/CacheList.d.ts
DELETED
|
@@ -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
|
-
}
|
package/lib/Utils/index.d.ts
DELETED
package/lib/index.d.ts
DELETED
package/lib/reactnative.d.ts
DELETED
package/lib/types/Cache.d.ts
DELETED
|
@@ -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
|
-
}
|
package/lib/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Cache';
|
package/lib-esm/.tsbuildinfo
DELETED