@aws-amplify/cache 4.0.63 → 4.0.64-unstable.4
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 +0 -11
- package/lib/.tsbuildinfo +3 -0
- package/lib/AsyncStorageCache.d.ts +154 -0
- package/lib/AsyncStorageCache.js +40 -101
- package/lib/AsyncStorageCache.js.map +1 -1
- package/lib/BrowserStorageCache.d.ts +165 -0
- package/lib/BrowserStorageCache.js +6 -31
- package/lib/BrowserStorageCache.js.map +1 -1
- package/lib/InMemoryCache.d.ts +131 -0
- package/lib/InMemoryCache.js +6 -43
- package/lib/InMemoryCache.js.map +1 -1
- package/lib/StorageCache.d.ts +31 -0
- package/lib/StorageCache.js +2 -16
- package/lib/StorageCache.js.map +1 -1
- package/lib/Utils/CacheList.d.ts +89 -0
- package/lib/Utils/CacheList.js +4 -24
- package/lib/Utils/CacheList.js.map +1 -1
- package/lib/Utils/CacheUtils.d.ts +24 -0
- package/lib/Utils/CacheUtils.js +2 -12
- package/lib/Utils/CacheUtils.js.map +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +8 -16
- package/lib/Utils/index.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +2 -18
- package/lib/index.js.map +1 -1
- package/lib/reactnative.d.ts +3 -0
- package/lib/reactnative.js +2 -18
- package/lib/reactnative.js.map +1 -1
- package/lib/types/Cache.d.ts +55 -0
- package/lib/types/Cache.js +2 -12
- package/lib/types/Cache.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -12
- package/lib/types/index.js.map +1 -1
- package/lib-esm/.tsbuildinfo +3 -0
- package/lib-esm/AsyncStorageCache.d.ts +1 -2
- package/lib-esm/AsyncStorageCache.js +6 -64
- package/lib-esm/AsyncStorageCache.js.map +1 -1
- package/lib-esm/BrowserStorageCache.d.ts +0 -4
- package/lib-esm/BrowserStorageCache.js +5 -30
- package/lib-esm/BrowserStorageCache.js.map +1 -1
- package/lib-esm/InMemoryCache.d.ts +0 -4
- package/lib-esm/InMemoryCache.js +3 -40
- package/lib-esm/InMemoryCache.js.map +1 -1
- package/lib-esm/StorageCache.d.ts +0 -4
- package/lib-esm/StorageCache.js +2 -16
- package/lib-esm/StorageCache.js.map +1 -1
- package/lib-esm/Utils/CacheList.js +3 -23
- package/lib-esm/Utils/CacheList.js.map +1 -1
- package/lib-esm/Utils/CacheUtils.js +2 -12
- package/lib-esm/Utils/CacheUtils.js.map +1 -1
- package/lib-esm/Utils/index.d.ts +1 -1
- package/lib-esm/Utils/index.js +3 -13
- package/lib-esm/Utils/index.js.map +1 -1
- package/lib-esm/index.d.ts +0 -4
- package/lib-esm/index.js +3 -18
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/reactnative.d.ts +2 -5
- package/lib-esm/reactnative.js +5 -19
- package/lib-esm/reactnative.js.map +1 -1
- package/lib-esm/types/Cache.js +2 -12
- package/lib-esm/types/Cache.js.map +1 -1
- package/lib-esm/types/index.js +2 -12
- package/lib-esm/types/index.js.map +1 -1
- package/package.json +15 -12
- package/src/AsyncStorageCache.ts +6 -15
- package/src/BrowserStorageCache.ts +4 -18
- package/src/InMemoryCache.ts +2 -16
- package/src/StorageCache.ts +2 -17
- package/src/Utils/CacheList.ts +2 -12
- package/src/Utils/CacheUtils.ts +2 -12
- package/src/Utils/index.ts +11 -15
- package/src/index.ts +4 -20
- package/src/reactnative.ts +5 -19
- package/src/types/Cache.ts +2 -12
- package/src/types/index.ts +2 -12
- package/build.js +0 -5
- package/dist/aws-amplify-cache.js +0 -1484
- package/dist/aws-amplify-cache.js.map +0 -1
- package/dist/aws-amplify-cache.min.js +0 -2
- package/dist/aws-amplify-cache.min.js.map +0 -1
- package/index.js +0 -7
- package/webpack.config.dev.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [4.0.63](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/cache@4.0.62...@aws-amplify/cache@4.0.63) (2022-11-04)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* Missing `cache` exports in React Native ([#10577](https://github.com/aws-amplify/amplify-js/issues/10577)) ([dabf01a](https://github.com/aws-amplify/amplify-js/commit/dabf01a76ea7d6133fe3d32fc24a9025c0b03c8f))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
6
|
## [4.0.62](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/cache@4.0.61...@aws-amplify/cache@4.0.62) (2022-10-27)
|
|
18
7
|
|
|
19
8
|
**Note:** Version bump only for package @aws-amplify/cache
|
package/lib/.tsbuildinfo
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { StorageCache } from './StorageCache';
|
|
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 };
|
package/lib/AsyncStorageCache.js
CHANGED
|
@@ -1,80 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
|
-
* the License. A copy of the License is located at
|
|
7
|
-
*
|
|
8
|
-
* http://aws.amazon.com/apache2.0/
|
|
9
|
-
*
|
|
10
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
11
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
12
|
-
* and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
var __extends = (this && this.__extends) || (function () {
|
|
15
|
-
var extendStatics = function (d, b) {
|
|
16
|
-
extendStatics = Object.setPrototypeOf ||
|
|
17
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
18
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
19
|
-
return extendStatics(d, b);
|
|
20
|
-
};
|
|
21
|
-
return function (d, b) {
|
|
22
|
-
extendStatics(d, b);
|
|
23
|
-
function __() { this.constructor = d; }
|
|
24
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
25
|
-
};
|
|
26
|
-
})();
|
|
27
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
-
function step(op) {
|
|
41
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
-
while (_) try {
|
|
43
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
44
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
-
switch (op[0]) {
|
|
46
|
-
case 0: case 1: t = op; break;
|
|
47
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
-
default:
|
|
51
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
-
if (t[2]) _.ops.pop();
|
|
56
|
-
_.trys.pop(); continue;
|
|
57
|
-
}
|
|
58
|
-
op = body.call(thisArg, _);
|
|
59
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
|
-
};
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
66
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
var core_1 = require("@aws-amplify/core");
|
|
7
|
+
var async_storage_1 = tslib_1.__importDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
+
exports.AsyncStorage = async_storage_1.default;
|
|
67
9
|
var StorageCache_1 = require("./StorageCache");
|
|
68
10
|
var Utils_1 = require("./Utils");
|
|
69
|
-
var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
70
|
-
exports.AsyncStorage = async_storage_1.default;
|
|
71
|
-
var core_1 = require("@aws-amplify/core");
|
|
72
11
|
var logger = new core_1.ConsoleLogger('AsyncStorageCache');
|
|
73
12
|
/*
|
|
74
13
|
* Customized cache which based on the AsyncStorage with LRU implemented
|
|
75
14
|
*/
|
|
76
15
|
var AsyncStorageCache = /** @class */ (function (_super) {
|
|
77
|
-
__extends(AsyncStorageCache, _super);
|
|
16
|
+
tslib_1.__extends(AsyncStorageCache, _super);
|
|
78
17
|
/**
|
|
79
18
|
* initialize the cache
|
|
80
19
|
*
|
|
@@ -98,9 +37,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
98
37
|
* @param amount - the amount of the cache size which needs to be decreased
|
|
99
38
|
*/
|
|
100
39
|
AsyncStorageCache.prototype._decreaseCurSizeInBytes = function (amount) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
102
41
|
var curSize;
|
|
103
|
-
return __generator(this, function (_a) {
|
|
42
|
+
return tslib_1.__generator(this, function (_a) {
|
|
104
43
|
switch (_a.label) {
|
|
105
44
|
case 0: return [4 /*yield*/, this.getCacheCurSize()];
|
|
106
45
|
case 1:
|
|
@@ -119,9 +58,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
119
58
|
* @param amount - the amount of the cache szie which need to be increased
|
|
120
59
|
*/
|
|
121
60
|
AsyncStorageCache.prototype._increaseCurSizeInBytes = function (amount) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
123
62
|
var curSize;
|
|
124
|
-
return __generator(this, function (_a) {
|
|
63
|
+
return tslib_1.__generator(this, function (_a) {
|
|
125
64
|
switch (_a.label) {
|
|
126
65
|
case 0: return [4 /*yield*/, this.getCacheCurSize()];
|
|
127
66
|
case 1:
|
|
@@ -143,8 +82,8 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
143
82
|
* @return the refreshed item
|
|
144
83
|
*/
|
|
145
84
|
AsyncStorageCache.prototype._refreshItem = function (item, prefixedKey) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
return __generator(this, function (_a) {
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
86
|
+
return tslib_1.__generator(this, function (_a) {
|
|
148
87
|
switch (_a.label) {
|
|
149
88
|
case 0:
|
|
150
89
|
item.visitedTime = Utils_1.getCurrTime();
|
|
@@ -164,9 +103,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
164
103
|
* @return true if the item is expired.
|
|
165
104
|
*/
|
|
166
105
|
AsyncStorageCache.prototype._isExpired = function (key) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
168
107
|
var text, item;
|
|
169
|
-
return __generator(this, function (_a) {
|
|
108
|
+
return tslib_1.__generator(this, function (_a) {
|
|
170
109
|
switch (_a.label) {
|
|
171
110
|
case 0: return [4 /*yield*/, async_storage_1.default.getItem(key)];
|
|
172
111
|
case 1:
|
|
@@ -187,9 +126,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
187
126
|
* @param size - optional, the byte size of the item
|
|
188
127
|
*/
|
|
189
128
|
AsyncStorageCache.prototype._removeItem = function (prefixedKey, size) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
191
130
|
var itemSize, _a, _b, _c, removeItemError_1;
|
|
192
|
-
return __generator(this, function (_d) {
|
|
131
|
+
return tslib_1.__generator(this, function (_d) {
|
|
193
132
|
switch (_d.label) {
|
|
194
133
|
case 0:
|
|
195
134
|
if (!size) return [3 /*break*/, 1];
|
|
@@ -237,9 +176,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
237
176
|
* @param itemSizeInBytes - the byte size of the item
|
|
238
177
|
*/
|
|
239
178
|
AsyncStorageCache.prototype._setItem = function (prefixedKey, item) {
|
|
240
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
241
180
|
var setItemErr_1;
|
|
242
|
-
return __generator(this, function (_a) {
|
|
181
|
+
return tslib_1.__generator(this, function (_a) {
|
|
243
182
|
switch (_a.label) {
|
|
244
183
|
case 0:
|
|
245
184
|
// first try to update the current size of the cache.
|
|
@@ -276,9 +215,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
276
215
|
* @return total space needed
|
|
277
216
|
*/
|
|
278
217
|
AsyncStorageCache.prototype._sizeToPop = function (itemSize) {
|
|
279
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
280
219
|
var spaceItemNeed, cacheThresholdSpace;
|
|
281
|
-
return __generator(this, function (_a) {
|
|
220
|
+
return tslib_1.__generator(this, function (_a) {
|
|
282
221
|
switch (_a.label) {
|
|
283
222
|
case 0: return [4 /*yield*/, this.getCacheCurSize()];
|
|
284
223
|
case 1:
|
|
@@ -299,9 +238,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
299
238
|
* @return true if cache is full
|
|
300
239
|
*/
|
|
301
240
|
AsyncStorageCache.prototype._isCacheFull = function (itemSize) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
303
242
|
var _a;
|
|
304
|
-
return __generator(this, function (_b) {
|
|
243
|
+
return tslib_1.__generator(this, function (_b) {
|
|
305
244
|
switch (_b.label) {
|
|
306
245
|
case 0:
|
|
307
246
|
_a = itemSize;
|
|
@@ -318,9 +257,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
318
257
|
* @return array of keys
|
|
319
258
|
*/
|
|
320
259
|
AsyncStorageCache.prototype._findValidKeys = function () {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
322
261
|
var keys, keyInCache, i, key;
|
|
323
|
-
return __generator(this, function (_a) {
|
|
262
|
+
return tslib_1.__generator(this, function (_a) {
|
|
324
263
|
switch (_a.label) {
|
|
325
264
|
case 0:
|
|
326
265
|
keys = [];
|
|
@@ -362,9 +301,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
362
301
|
* @param sizeToPop - the total size of the items which needed to be poped out
|
|
363
302
|
*/
|
|
364
303
|
AsyncStorageCache.prototype._popOutItems = function (keys, sizeToPop) {
|
|
365
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
366
305
|
var items, remainedSize, i, val, item, i;
|
|
367
|
-
return __generator(this, function (_a) {
|
|
306
|
+
return tslib_1.__generator(this, function (_a) {
|
|
368
307
|
switch (_a.label) {
|
|
369
308
|
case 0:
|
|
370
309
|
items = [];
|
|
@@ -442,9 +381,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
442
381
|
* @return {Prmoise}
|
|
443
382
|
*/
|
|
444
383
|
AsyncStorageCache.prototype.setItem = function (key, value, options) {
|
|
445
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
446
385
|
var prefixedKey, cacheItemOptions, item, val, validKeys, sizeToPop, e_1;
|
|
447
|
-
return __generator(this, function (_a) {
|
|
386
|
+
return tslib_1.__generator(this, function (_a) {
|
|
448
387
|
switch (_a.label) {
|
|
449
388
|
case 0:
|
|
450
389
|
logger.debug("Set item: key is " + key + ", value is " + value + " with options: " + options);
|
|
@@ -535,9 +474,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
535
474
|
* @return {Promise} - return a promise resolves to be the value of the item
|
|
536
475
|
*/
|
|
537
476
|
AsyncStorageCache.prototype.getItem = function (key, options) {
|
|
538
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
477
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
539
478
|
var ret, prefixedKey, item, val, e_2;
|
|
540
|
-
return __generator(this, function (_a) {
|
|
479
|
+
return tslib_1.__generator(this, function (_a) {
|
|
541
480
|
switch (_a.label) {
|
|
542
481
|
case 0:
|
|
543
482
|
logger.debug("Get item: key is " + key + " with options " + options);
|
|
@@ -596,9 +535,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
596
535
|
* @return {Promise}
|
|
597
536
|
*/
|
|
598
537
|
AsyncStorageCache.prototype.removeItem = function (key) {
|
|
599
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
538
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
600
539
|
var prefixedKey, val, e_3;
|
|
601
|
-
return __generator(this, function (_a) {
|
|
540
|
+
return tslib_1.__generator(this, function (_a) {
|
|
602
541
|
switch (_a.label) {
|
|
603
542
|
case 0:
|
|
604
543
|
logger.debug("Remove item: key is " + key);
|
|
@@ -635,9 +574,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
635
574
|
* @return {Promise}
|
|
636
575
|
*/
|
|
637
576
|
AsyncStorageCache.prototype.clear = function () {
|
|
638
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
577
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
639
578
|
var keys, keysToRemove, i, i, e_4;
|
|
640
|
-
return __generator(this, function (_a) {
|
|
579
|
+
return tslib_1.__generator(this, function (_a) {
|
|
641
580
|
switch (_a.label) {
|
|
642
581
|
case 0:
|
|
643
582
|
logger.debug("Clear Cache");
|
|
@@ -679,9 +618,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
679
618
|
* @return {Promise}
|
|
680
619
|
*/
|
|
681
620
|
AsyncStorageCache.prototype.getCacheCurSize = function () {
|
|
682
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
621
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
683
622
|
var ret;
|
|
684
|
-
return __generator(this, function (_a) {
|
|
623
|
+
return tslib_1.__generator(this, function (_a) {
|
|
685
624
|
switch (_a.label) {
|
|
686
625
|
case 0: return [4 /*yield*/, async_storage_1.default.getItem(this.cacheCurSizeKey)];
|
|
687
626
|
case 1:
|
|
@@ -703,9 +642,9 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
703
642
|
* @return {Promise}
|
|
704
643
|
*/
|
|
705
644
|
AsyncStorageCache.prototype.getAllKeys = function () {
|
|
706
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
645
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
707
646
|
var keys, retKeys, i, e_5;
|
|
708
|
-
return __generator(this, function (_a) {
|
|
647
|
+
return tslib_1.__generator(this, function (_a) {
|
|
709
648
|
switch (_a.label) {
|
|
710
649
|
case 0:
|
|
711
650
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -746,5 +685,5 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
746
685
|
exports.AsyncStorageCache = AsyncStorageCache;
|
|
747
686
|
var instance = new AsyncStorageCache();
|
|
748
687
|
exports.Cache = instance;
|
|
749
|
-
|
|
688
|
+
core_1.Amplify.register(instance);
|
|
750
689
|
//# sourceMappingURL=AsyncStorageCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncStorageCache.js","sourceRoot":"","sources":["../src/AsyncStorageCache.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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0CAAc,GAAd,UAAe,MAAM;QACpB,IAAI,MAAM,CAAC,SAAS,KAAK,qBAAa,CAAC,SAAS,EAAE;YACjD,MAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACpE,MAAM,CAAC,SAAS,GAAG,mBAAW,CAAC,QAAQ,EAAE,CAAC;SAC1C;QACD,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACF,wBAAC;AAAD,CAAC,AAjdD,CAAuC,2BAAY,GAidlD;AAjdY,8CAAiB;AAmd9B,IAAM,QAAQ,GAAW,IAAI,iBAAiB,EAAE,CAAC;AACd,yBAAK;AAExC,cAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -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;
|