@aws-amplify/cache 4.0.51-next.32 → 4.0.51-next.36
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/lib/AsyncStorageCache.d.ts +155 -0
- package/lib/AsyncStorageCache.js +1 -1
- package/lib/BrowserStorageCache.d.ts +165 -0
- package/lib/BrowserStorageCache.js +1 -1
- package/lib/InMemoryCache.d.ts +131 -0
- package/lib/InMemoryCache.js +1 -1
- package/lib/StorageCache.d.ts +31 -0
- package/lib/StorageCache.js +1 -1
- package/lib/Utils/CacheList.d.ts +89 -0
- package/lib/Utils/CacheList.js +1 -1
- package/lib/Utils/CacheUtils.d.ts +24 -0
- package/lib/Utils/CacheUtils.js +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +7 -3
- package/lib/Utils/index.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/reactnative.d.ts +3 -0
- package/lib/reactnative.js +1 -1
- package/lib/reactnative.js.map +1 -1
- package/lib/types/Cache.d.ts +55 -0
- package/lib/types/Cache.js +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -1
- package/lib-esm/AsyncStorageCache.js +1 -1
- package/lib-esm/BrowserStorageCache.js +1 -1
- package/lib-esm/InMemoryCache.js +1 -1
- package/lib-esm/StorageCache.js +1 -1
- package/lib-esm/Utils/CacheList.js +1 -1
- package/lib-esm/Utils/CacheUtils.js +1 -1
- package/lib-esm/Utils/index.d.ts +1 -1
- package/lib-esm/Utils/index.js +2 -2
- package/lib-esm/Utils/index.js.map +1 -1
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +3 -1
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/reactnative.d.ts +2 -1
- package/lib-esm/reactnative.js +4 -2
- package/lib-esm/reactnative.js.map +1 -1
- package/lib-esm/types/Cache.js +1 -1
- package/lib-esm/types/index.js +1 -1
- package/package.json +5 -4
- package/src/AsyncStorageCache.ts +1 -1
- package/src/BrowserStorageCache.ts +1 -1
- package/src/InMemoryCache.ts +1 -1
- package/src/StorageCache.ts +1 -1
- package/src/Utils/CacheList.ts +1 -1
- package/src/Utils/CacheUtils.ts +1 -1
- package/src/Utils/index.ts +21 -15
- package/src/index.ts +4 -1
- package/src/reactnative.ts +5 -2
- package/src/types/Cache.ts +1 -1
- package/src/types/index.ts +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { StorageCache } from './StorageCache';
|
|
2
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
+
import { ICache } from './types';
|
|
4
|
+
export declare class AsyncStorageCache extends StorageCache implements ICache {
|
|
5
|
+
/**
|
|
6
|
+
* initialize the cache
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} config - the configuration of the cache
|
|
9
|
+
*/
|
|
10
|
+
constructor(config?: any);
|
|
11
|
+
/**
|
|
12
|
+
* decrease current size of the cache
|
|
13
|
+
* @private
|
|
14
|
+
* @param amount - the amount of the cache size which needs to be decreased
|
|
15
|
+
*/
|
|
16
|
+
_decreaseCurSizeInBytes(amount: any): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* increase current size of the cache
|
|
19
|
+
* @private
|
|
20
|
+
* @param amount - the amount of the cache szie which need to be increased
|
|
21
|
+
*/
|
|
22
|
+
_increaseCurSizeInBytes(amount: any): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* update the visited time if item has been visited
|
|
25
|
+
* @private
|
|
26
|
+
* @param item - the item which need to be refreshed
|
|
27
|
+
* @param prefixedKey - the key of the item
|
|
28
|
+
*
|
|
29
|
+
* @return the refreshed item
|
|
30
|
+
*/
|
|
31
|
+
_refreshItem(item: any, prefixedKey: any): Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* check wether item is expired
|
|
34
|
+
* @private
|
|
35
|
+
* @param key - the key of the item
|
|
36
|
+
*
|
|
37
|
+
* @return true if the item is expired.
|
|
38
|
+
*/
|
|
39
|
+
_isExpired(key: any): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* delete item from cache
|
|
42
|
+
* @private
|
|
43
|
+
* @param prefixedKey - the key of the item
|
|
44
|
+
* @param size - optional, the byte size of the item
|
|
45
|
+
*/
|
|
46
|
+
_removeItem(prefixedKey: any, size?: any): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* put item into cache
|
|
49
|
+
* @private
|
|
50
|
+
* @param prefixedKey - the key of the item
|
|
51
|
+
* @param itemData - the value of the item
|
|
52
|
+
* @param itemSizeInBytes - the byte size of the item
|
|
53
|
+
*/
|
|
54
|
+
_setItem(prefixedKey: any, item: any): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* total space needed when poping out items
|
|
57
|
+
* @private
|
|
58
|
+
* @param itemSize
|
|
59
|
+
*
|
|
60
|
+
* @return total space needed
|
|
61
|
+
*/
|
|
62
|
+
_sizeToPop(itemSize: any): Promise<number>;
|
|
63
|
+
/**
|
|
64
|
+
* see whether cache is full
|
|
65
|
+
* @private
|
|
66
|
+
* @param itemSize
|
|
67
|
+
*
|
|
68
|
+
* @return true if cache is full
|
|
69
|
+
*/
|
|
70
|
+
_isCacheFull(itemSize: any): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* scan the storage and find out all the keys owned by this cache
|
|
73
|
+
* also clean the expired keys while scanning
|
|
74
|
+
* @private
|
|
75
|
+
* @return array of keys
|
|
76
|
+
*/
|
|
77
|
+
_findValidKeys(): Promise<any[]>;
|
|
78
|
+
/**
|
|
79
|
+
* get all the items we have, sort them by their priority,
|
|
80
|
+
* if priority is same, sort them by their last visited time
|
|
81
|
+
* pop out items from the low priority (5 is the lowest)
|
|
82
|
+
* @private
|
|
83
|
+
* @param keys - all the keys in this cache
|
|
84
|
+
* @param sizeToPop - the total size of the items which needed to be poped out
|
|
85
|
+
*/
|
|
86
|
+
_popOutItems(keys: any, sizeToPop: any): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Set item into cache. You can put number, string, boolean or object.
|
|
89
|
+
* The cache will first check whether has the same key.
|
|
90
|
+
* If it has, it will delete the old item and then put the new item in
|
|
91
|
+
* The cache will pop out items if it is full
|
|
92
|
+
* You can specify the cache item options. The cache will abort and output a warning:
|
|
93
|
+
* If the key is invalid
|
|
94
|
+
* If the size of the item exceeds itemMaxSize.
|
|
95
|
+
* If the value is undefined
|
|
96
|
+
* If incorrect cache item configuration
|
|
97
|
+
* If error happened with browser storage
|
|
98
|
+
*
|
|
99
|
+
* @param {String} key - the key of the item
|
|
100
|
+
* @param {Object} value - the value of the item
|
|
101
|
+
* @param {Object} [options] - optional, the specified meta-data
|
|
102
|
+
* @return {Prmoise}
|
|
103
|
+
*/
|
|
104
|
+
setItem(key: any, value: any, options: any): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Get item from cache. It will return null if item doesn’t exist or it has been expired.
|
|
107
|
+
* If you specified callback function in the options,
|
|
108
|
+
* then the function will be executed if no such item in the cache
|
|
109
|
+
* and finally put the return value into cache.
|
|
110
|
+
* Please make sure the callback function will return the value you want to put into the cache.
|
|
111
|
+
* The cache will abort output a warning:
|
|
112
|
+
* If the key is invalid
|
|
113
|
+
* If error happened with AsyncStorage
|
|
114
|
+
*
|
|
115
|
+
* @param {String} key - the key of the item
|
|
116
|
+
* @param {Object} [options] - the options of callback function
|
|
117
|
+
* @return {Promise} - return a promise resolves to be the value of the item
|
|
118
|
+
*/
|
|
119
|
+
getItem(key: any, options: any): Promise<any>;
|
|
120
|
+
/**
|
|
121
|
+
* remove item from the cache
|
|
122
|
+
* The cache will abort output a warning:
|
|
123
|
+
* If error happened with AsyncStorage
|
|
124
|
+
* @param {String} key - the key of the item
|
|
125
|
+
* @return {Promise}
|
|
126
|
+
*/
|
|
127
|
+
removeItem(key: any): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* clear the entire cache
|
|
130
|
+
* The cache will abort output a warning:
|
|
131
|
+
* If error happened with AsyncStorage
|
|
132
|
+
* @return {Promise}
|
|
133
|
+
*/
|
|
134
|
+
clear(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* return the current size of the cache
|
|
137
|
+
* @return {Promise}
|
|
138
|
+
*/
|
|
139
|
+
getCacheCurSize(): Promise<number>;
|
|
140
|
+
/**
|
|
141
|
+
* Return all the keys in the cache.
|
|
142
|
+
* Will return an empty array if error happend.
|
|
143
|
+
* @return {Promise}
|
|
144
|
+
*/
|
|
145
|
+
getAllKeys(): Promise<any[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Return a new instance of cache with customized configuration.
|
|
148
|
+
* @param {Object} config - the customized configuration
|
|
149
|
+
* @return {Object} - the new instance of Cache
|
|
150
|
+
*/
|
|
151
|
+
createInstance(config: any): ICache;
|
|
152
|
+
}
|
|
153
|
+
declare const instance: ICache;
|
|
154
|
+
export { AsyncStorage, instance as Cache };
|
|
155
|
+
export default instance;
|
package/lib/AsyncStorageCache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { StorageCache } from './StorageCache';
|
|
2
|
+
import { ICache, CacheConfig, CacheItemOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Customized storage based on the SessionStorage or LocalStorage with LRU implemented
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserStorageCacheClass extends StorageCache implements ICache {
|
|
7
|
+
/**
|
|
8
|
+
* initialize the cache
|
|
9
|
+
* @param config - the configuration of the cache
|
|
10
|
+
*/
|
|
11
|
+
constructor(config?: CacheConfig);
|
|
12
|
+
/**
|
|
13
|
+
* decrease current size of the cache
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @param amount - the amount of the cache size which needs to be decreased
|
|
17
|
+
*/
|
|
18
|
+
private _decreaseCurSizeInBytes;
|
|
19
|
+
/**
|
|
20
|
+
* increase current size of the cache
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
* @param amount - the amount of the cache szie which need to be increased
|
|
24
|
+
*/
|
|
25
|
+
private _increaseCurSizeInBytes;
|
|
26
|
+
/**
|
|
27
|
+
* update the visited time if item has been visited
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
* @param item - the item which need to be refreshed
|
|
31
|
+
* @param prefixedKey - the key of the item
|
|
32
|
+
*
|
|
33
|
+
* @return the refreshed item
|
|
34
|
+
*/
|
|
35
|
+
private _refreshItem;
|
|
36
|
+
/**
|
|
37
|
+
* check wether item is expired
|
|
38
|
+
*
|
|
39
|
+
* @private
|
|
40
|
+
* @param key - the key of the item
|
|
41
|
+
*
|
|
42
|
+
* @return true if the item is expired.
|
|
43
|
+
*/
|
|
44
|
+
private _isExpired;
|
|
45
|
+
/**
|
|
46
|
+
* delete item from cache
|
|
47
|
+
*
|
|
48
|
+
* @private
|
|
49
|
+
* @param prefixedKey - the key of the item
|
|
50
|
+
* @param size - optional, the byte size of the item
|
|
51
|
+
*/
|
|
52
|
+
private _removeItem;
|
|
53
|
+
/**
|
|
54
|
+
* put item into cache
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @param prefixedKey - the key of the item
|
|
58
|
+
* @param itemData - the value of the item
|
|
59
|
+
* @param itemSizeInBytes - the byte size of the item
|
|
60
|
+
*/
|
|
61
|
+
private _setItem;
|
|
62
|
+
/**
|
|
63
|
+
* total space needed when poping out items
|
|
64
|
+
*
|
|
65
|
+
* @private
|
|
66
|
+
* @param itemSize
|
|
67
|
+
*
|
|
68
|
+
* @return total space needed
|
|
69
|
+
*/
|
|
70
|
+
private _sizeToPop;
|
|
71
|
+
/**
|
|
72
|
+
* see whether cache is full
|
|
73
|
+
*
|
|
74
|
+
* @private
|
|
75
|
+
* @param itemSize
|
|
76
|
+
*
|
|
77
|
+
* @return true if cache is full
|
|
78
|
+
*/
|
|
79
|
+
private _isCacheFull;
|
|
80
|
+
/**
|
|
81
|
+
* scan the storage and find out all the keys owned by this cache
|
|
82
|
+
* also clean the expired keys while scanning
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*
|
|
86
|
+
* @return array of keys
|
|
87
|
+
*/
|
|
88
|
+
private _findValidKeys;
|
|
89
|
+
/**
|
|
90
|
+
* get all the items we have, sort them by their priority,
|
|
91
|
+
* if priority is same, sort them by their last visited time
|
|
92
|
+
* pop out items from the low priority (5 is the lowest)
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
* @param keys - all the keys in this cache
|
|
96
|
+
* @param sizeToPop - the total size of the items which needed to be poped out
|
|
97
|
+
*/
|
|
98
|
+
private _popOutItems;
|
|
99
|
+
/**
|
|
100
|
+
* Set item into cache. You can put number, string, boolean or object.
|
|
101
|
+
* The cache will first check whether has the same key.
|
|
102
|
+
* If it has, it will delete the old item and then put the new item in
|
|
103
|
+
* The cache will pop out items if it is full
|
|
104
|
+
* You can specify the cache item options. The cache will abort and output a warning:
|
|
105
|
+
* If the key is invalid
|
|
106
|
+
* If the size of the item exceeds itemMaxSize.
|
|
107
|
+
* If the value is undefined
|
|
108
|
+
* If incorrect cache item configuration
|
|
109
|
+
* If error happened with browser storage
|
|
110
|
+
*
|
|
111
|
+
* @param key - the key of the item
|
|
112
|
+
* @param value - the value of the item
|
|
113
|
+
* @param {Object} [options] - optional, the specified meta-data
|
|
114
|
+
*/
|
|
115
|
+
setItem(key: string, value: object | number | string | boolean, options?: CacheItemOptions): void;
|
|
116
|
+
/**
|
|
117
|
+
* Get item from cache. It will return null if item doesn’t exist or it has been expired.
|
|
118
|
+
* If you specified callback function in the options,
|
|
119
|
+
* then the function will be executed if no such item in the cache
|
|
120
|
+
* and finally put the return value into cache.
|
|
121
|
+
* Please make sure the callback function will return the value you want to put into the cache.
|
|
122
|
+
* The cache will abort output a warning:
|
|
123
|
+
* If the key is invalid
|
|
124
|
+
* If error happened with browser storage
|
|
125
|
+
*
|
|
126
|
+
* @param key - the key of the item
|
|
127
|
+
* @param {Object} [options] - the options of callback function
|
|
128
|
+
*
|
|
129
|
+
* @return - return the value of the item
|
|
130
|
+
*/
|
|
131
|
+
getItem(key: string, options?: CacheItemOptions): any;
|
|
132
|
+
/**
|
|
133
|
+
* remove item from the cache
|
|
134
|
+
* The cache will abort output a warning:
|
|
135
|
+
* If error happened with browser storage
|
|
136
|
+
* @param key - the key of the item
|
|
137
|
+
*/
|
|
138
|
+
removeItem(key: string): void;
|
|
139
|
+
/**
|
|
140
|
+
* clear the entire cache
|
|
141
|
+
* The cache will abort output a warning:
|
|
142
|
+
* If error happened with browser storage
|
|
143
|
+
*/
|
|
144
|
+
clear(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Return all the keys in the cache.
|
|
147
|
+
*
|
|
148
|
+
* @return - all keys in the cache
|
|
149
|
+
*/
|
|
150
|
+
getAllKeys(): string[];
|
|
151
|
+
/**
|
|
152
|
+
* return the current size of the cache
|
|
153
|
+
*
|
|
154
|
+
* @return - current size of the cache
|
|
155
|
+
*/
|
|
156
|
+
getCacheCurSize(): number;
|
|
157
|
+
/**
|
|
158
|
+
* Return a new instance of cache with customized configuration.
|
|
159
|
+
* @param config - the customized configuration
|
|
160
|
+
*
|
|
161
|
+
* @return - new instance of Cache
|
|
162
|
+
*/
|
|
163
|
+
createInstance(config: CacheConfig): ICache;
|
|
164
|
+
}
|
|
165
|
+
export declare const BrowserStorageCache: ICache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1,131 @@
|
|
|
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;
|
package/lib/InMemoryCache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
package/lib/StorageCache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
}
|
package/lib/Utils/CacheList.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1,24 @@
|
|
|
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/CacheUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
package/lib/Utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
* and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
var
|
|
16
|
-
|
|
15
|
+
var CacheUtils_1 = require("./CacheUtils");
|
|
16
|
+
exports.CacheObject = CacheUtils_1.CacheObject;
|
|
17
|
+
exports.defaultConfig = CacheUtils_1.defaultConfig;
|
|
18
|
+
exports.getByteLength = CacheUtils_1.getByteLength;
|
|
19
|
+
exports.getCurrTime = CacheUtils_1.getCurrTime;
|
|
20
|
+
exports.isInteger = CacheUtils_1.isInteger;
|
|
17
21
|
var CacheList_1 = require("./CacheList");
|
|
18
22
|
exports.CacheList = CacheList_1.default;
|
|
19
23
|
//# sourceMappingURL=index.js.map
|
package/lib/Utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,2CAMsB;AALrB,mCAAA,WAAW,CAAA;AACX,qCAAA,aAAa,CAAA;AACb,qCAAA,aAAa,CAAA;AACb,mCAAA,WAAW,CAAA;AACX,iCAAA,SAAS,CAAA;AAEV,yCAAmD;AAA1C,gCAAA,OAAO,CAAa"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
var core_1 = require("@aws-amplify/core");
|
|
16
16
|
var BrowserStorageCache_1 = require("./BrowserStorageCache");
|
|
17
17
|
exports.BrowserStorageCache = BrowserStorageCache_1.BrowserStorageCache;
|
|
18
|
+
exports.Cache = BrowserStorageCache_1.BrowserStorageCache;
|
|
18
19
|
var InMemoryCache_1 = require("./InMemoryCache");
|
|
19
20
|
exports.InMemoryCache = InMemoryCache_1.InMemoryCache;
|
|
20
21
|
core_1.Amplify.register(BrowserStorageCache_1.BrowserStorageCache);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,0CAA4C;AAC5C,6DAA4D;AAInD,8BAJA,yCAAmB,CAIA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,0CAA4C;AAC5C,6DAA4D;AAInD,8BAJA,yCAAmB,CAIA;AAGI,gBAPvB,yCAAmB,CAOS;AANrC,iDAAgD;AAGlB,wBAHrB,6BAAa,CAGqB;AAK3C,cAAO,CAAC,QAAQ,CAAC,yCAAmB,CAAC,CAAC"}
|
package/lib/reactnative.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
package/lib/reactnative.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnative.js","sourceRoot":"","sources":["../src/reactnative.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,0CAA4C;AAC5C,yDAA+D;
|
|
1
|
+
{"version":3,"file":"reactnative.js","sourceRoot":"","sources":["../src/reactnative.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,0CAA4C;AAC5C,yDAA+D;AAKtD,gBALA,yBAAK,CAKA;AAHL,4BAFO,qCAAiB,CAEP;AAK1B,cAAO,CAAC,QAAQ,CAAC,yBAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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/Cache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Cache';
|
package/lib/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright 2017-
|
|
3
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
6
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/lib-esm/InMemoryCache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/lib-esm/StorageCache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/lib-esm/Utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { CacheObject, defaultConfig, getByteLength, getCurrTime, isInteger, } from './CacheUtils';
|
|
2
2
|
export { default as CacheList } from './CacheList';
|
package/lib-esm/Utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
11
|
* and limitations under the License.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export { CacheObject, defaultConfig, getByteLength, getCurrTime, isInteger, } from './CacheUtils';
|
|
14
14
|
export { default as CacheList } from './CacheList';
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,EACX,SAAS,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/lib-esm/index.d.ts
CHANGED
package/lib-esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -14,5 +14,7 @@ import { Amplify } from '@aws-amplify/core';
|
|
|
14
14
|
import { BrowserStorageCache } from './BrowserStorageCache';
|
|
15
15
|
import { InMemoryCache } from './InMemoryCache';
|
|
16
16
|
export { BrowserStorageCache, InMemoryCache };
|
|
17
|
+
// Standard `Cache` export to maintain interoperability with React Native
|
|
18
|
+
export { BrowserStorageCache as Cache };
|
|
17
19
|
Amplify.register(BrowserStorageCache);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/lib-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAe,CAAC;AAE3D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAe,CAAC;AAE3D,yEAAyE;AACzE,OAAO,EAAE,mBAAmB,IAAI,KAAK,EAAE,CAAC;AAExC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC"}
|
package/lib-esm/reactnative.d.ts
CHANGED
package/lib-esm/reactnative.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Amplify } from '@aws-amplify/core';
|
|
14
14
|
import { Cache, AsyncStorageCache } from './AsyncStorageCache';
|
|
15
|
-
export {
|
|
15
|
+
export { AsyncStorageCache };
|
|
16
|
+
// Standard `Cache` export to maintain interoperability with React Native
|
|
17
|
+
export { Cache };
|
|
16
18
|
Amplify.register(Cache);
|
|
17
19
|
//# sourceMappingURL=reactnative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnative.js","sourceRoot":"","sources":["../src/reactnative.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reactnative.js","sourceRoot":"","sources":["../src/reactnative.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,yEAAyE;AACzE,OAAO,EAAE,KAAK,EAAE,CAAC;AAEjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC"}
|
package/lib-esm/types/Cache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/lib-esm/types/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/cache",
|
|
3
|
-
"version": "4.0.51-next.
|
|
3
|
+
"version": "4.0.51-next.36+580cda186",
|
|
4
4
|
"description": "Cache category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
32
32
|
"clean": "rimraf lib-esm lib dist",
|
|
33
33
|
"format": "echo \"Not implemented\"",
|
|
34
|
-
"lint": "tslint 'src/**/*.ts'"
|
|
34
|
+
"lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
|
|
35
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.74"
|
|
35
36
|
},
|
|
36
37
|
"repository": {
|
|
37
38
|
"type": "git",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"src"
|
|
50
51
|
],
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@aws-amplify/core": "4.6.2-next.
|
|
53
|
+
"@aws-amplify/core": "4.6.2-next.36+580cda186",
|
|
53
54
|
"tslib": "^2.0.0"
|
|
54
55
|
},
|
|
55
56
|
"jest": {
|
|
@@ -100,5 +101,5 @@
|
|
|
100
101
|
"lib-esm"
|
|
101
102
|
]
|
|
102
103
|
},
|
|
103
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "580cda186f10ead3bb99acb7a4825c435c657d33"
|
|
104
105
|
}
|
package/src/AsyncStorageCache.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/InMemoryCache.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/StorageCache.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/Utils/CacheList.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/Utils/CacheUtils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/Utils/index.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2017-
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
-
* the License. A copy of the License is located at
|
|
6
|
-
*
|
|
7
|
-
* http://aws.amazon.com/apache2.0/
|
|
8
|
-
*
|
|
9
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
-
* and limitations under the License.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
CacheObject,
|
|
16
|
+
defaultConfig,
|
|
17
|
+
getByteLength,
|
|
18
|
+
getCurrTime,
|
|
19
|
+
isInteger,
|
|
20
|
+
} from './CacheUtils';
|
|
21
|
+
export { default as CacheList } from './CacheList';
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -18,4 +18,7 @@ import { CacheConfig } from './types';
|
|
|
18
18
|
|
|
19
19
|
export { BrowserStorageCache, InMemoryCache, CacheConfig };
|
|
20
20
|
|
|
21
|
+
// Standard `Cache` export to maintain interoperability with React Native
|
|
22
|
+
export { BrowserStorageCache as Cache };
|
|
23
|
+
|
|
21
24
|
Amplify.register(BrowserStorageCache);
|
package/src/reactnative.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
import { Amplify } from '@aws-amplify/core';
|
|
15
15
|
import { Cache, AsyncStorageCache } from './AsyncStorageCache';
|
|
16
16
|
|
|
17
|
-
export {
|
|
17
|
+
export { AsyncStorageCache };
|
|
18
|
+
|
|
19
|
+
// Standard `Cache` export to maintain interoperability with React Native
|
|
20
|
+
export { Cache };
|
|
18
21
|
|
|
19
22
|
Amplify.register(Cache);
|
package/src/types/Cache.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|