@next2d/cache 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/package.json +26 -0
- package/src/CacheStore/service/CacheStoreDestroyService.d.ts +11 -0
- package/src/CacheStore/service/CacheStoreDestroyService.js +25 -0
- package/src/CacheStore/service/CacheStoreGenerateFilterKeysService.d.ts +13 -0
- package/src/CacheStore/service/CacheStoreGenerateFilterKeysService.js +15 -0
- package/src/CacheStore/service/CacheStoreGenerateKeysService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreGenerateKeysService.js +29 -0
- package/src/CacheStore/service/CacheStoreGetService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreGetService.js +19 -0
- package/src/CacheStore/service/CacheStoreHasService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreHasService.js +19 -0
- package/src/CacheStore/service/CacheStoreRemoveByIdService.d.ts +10 -0
- package/src/CacheStore/service/CacheStoreRemoveByIdService.js +20 -0
- package/src/CacheStore/service/CacheStoreRemoveService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreRemoveService.js +27 -0
- package/src/CacheStore/service/CacheStoreRemoveTimerScheduledCacheService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreRemoveTimerScheduledCacheService.js +24 -0
- package/src/CacheStore/service/CacheStoreRemoveTimerService.d.ts +14 -0
- package/src/CacheStore/service/CacheStoreRemoveTimerService.js +32 -0
- package/src/CacheStore/service/CacheStoreResetService.d.ts +12 -0
- package/src/CacheStore/service/CacheStoreResetService.js +28 -0
- package/src/CacheStore/service/CacheStoreSetService.d.ts +14 -0
- package/src/CacheStore/service/CacheStoreSetService.js +34 -0
- package/src/CacheStore.d.ts +200 -0
- package/src/CacheStore.js +274 -0
- package/src/CacheUtil.d.ts +28 -0
- package/src/CacheUtil.js +35 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Next2D
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@next2d/cache",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Next2D Cache Package",
|
|
5
|
+
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://next2d.app",
|
|
8
|
+
"bugs": "https://github.com/Next2D/Player/issues",
|
|
9
|
+
"main": "src/index.js",
|
|
10
|
+
"types": "src/index.d.ts",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"Next2D",
|
|
20
|
+
"Next2D Cache"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 破棄するHTMLCanvasElementをプールに保管
|
|
3
|
+
* Store the HTMLCanvasElement to be destroyed in the pool
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLCanvasElement[]} pool
|
|
6
|
+
* @param {object} object
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (pool: HTMLCanvasElement[], object: any) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 破棄するHTMLCanvasElementをプールに保管
|
|
3
|
+
* Store the HTMLCanvasElement to be destroyed in the pool
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLCanvasElement[]} pool
|
|
6
|
+
* @param {object} object
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export const execute = (pool, object) => {
|
|
12
|
+
if (!object || typeof object !== "object") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if ("canvas" in object) {
|
|
16
|
+
const canvas = object.canvas;
|
|
17
|
+
const width = canvas.width;
|
|
18
|
+
const height = canvas.height;
|
|
19
|
+
object.clearRect(0, 0, width + 1, height + 1);
|
|
20
|
+
// canvas reset
|
|
21
|
+
canvas.width = canvas.height = 1;
|
|
22
|
+
// pool
|
|
23
|
+
pool.push(canvas);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアのキーを生成
|
|
3
|
+
* Generate cache store keys
|
|
4
|
+
*
|
|
5
|
+
* @param {number} a
|
|
6
|
+
* @param {number} b
|
|
7
|
+
* @param {number} c
|
|
8
|
+
* @param {number} d
|
|
9
|
+
* @return {string}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: (a: number, b: number, c: number, d: number) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアのキーを生成
|
|
3
|
+
* Generate cache store keys
|
|
4
|
+
*
|
|
5
|
+
* @param {number} a
|
|
6
|
+
* @param {number} b
|
|
7
|
+
* @param {number} c
|
|
8
|
+
* @param {number} d
|
|
9
|
+
* @return {string}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const execute = (a, b, c, d) => {
|
|
14
|
+
return `${a}${b}${c}${d}`;
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアのキーを生成
|
|
3
|
+
* Generate cache store keys
|
|
4
|
+
*
|
|
5
|
+
* @param {number} x_scale
|
|
6
|
+
* @param {number} y_scale
|
|
7
|
+
* @param {number} alpha
|
|
8
|
+
* @return {number}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (x_scale: number, y_scale: number, alpha: number) => number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアのキーを生成
|
|
3
|
+
* Generate cache store keys
|
|
4
|
+
*
|
|
5
|
+
* @param {number} x_scale
|
|
6
|
+
* @param {number} y_scale
|
|
7
|
+
* @param {number} alpha
|
|
8
|
+
* @return {number}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (x_scale, y_scale, alpha) => {
|
|
13
|
+
const values = [x_scale * 10000, y_scale * 10000];
|
|
14
|
+
if (alpha) {
|
|
15
|
+
values.push(alpha * 100);
|
|
16
|
+
}
|
|
17
|
+
let hash = 2166136261; // FNV-1aオフセット basis
|
|
18
|
+
for (let idx = 0; idx < values.length; ++idx) {
|
|
19
|
+
let num = values[idx] | 0; // 整数として扱う
|
|
20
|
+
// 32bit整数の各バイトを処理
|
|
21
|
+
for (let i = 0; i < 4; i++) {
|
|
22
|
+
const byte = num & 0xff;
|
|
23
|
+
hash ^= byte;
|
|
24
|
+
hash = Math.imul(hash, 16777619); // FNV-1a の FNV prime
|
|
25
|
+
num >>>= 8;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return (hash >>> 0) % 16777216;
|
|
29
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 指定のキーからデータを取得
|
|
3
|
+
* Get data from the specified key
|
|
4
|
+
*
|
|
5
|
+
* @param {Map} data_store
|
|
6
|
+
* @param {string} unique_key
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @return {*}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (data_store: Map<string, Map<string, any>>, unique_key: string, key: string) => any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 指定のキーからデータを取得
|
|
3
|
+
* Get data from the specified key
|
|
4
|
+
*
|
|
5
|
+
* @param {Map} data_store
|
|
6
|
+
* @param {string} unique_key
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @return {*}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (data_store, unique_key, key) => {
|
|
13
|
+
const data = data_store.get(unique_key) || null;
|
|
14
|
+
if (!data) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
data.delete("trash");
|
|
18
|
+
return data.get(key) || null;
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 指定キーのキャッシュが存在するかどうか
|
|
3
|
+
* Whether the specified key cache exists
|
|
4
|
+
*
|
|
5
|
+
* @param {Map} data_store
|
|
6
|
+
* @param {string} unique_key
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @return {boolean}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (data_store: Map<string, Map<string, any>>, unique_key: string, key?: string) => boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 指定キーのキャッシュが存在するかどうか
|
|
3
|
+
* Whether the specified key cache exists
|
|
4
|
+
*
|
|
5
|
+
* @param {Map} data_store
|
|
6
|
+
* @param {string} unique_key
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @return {boolean}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (data_store, unique_key, key = "") => {
|
|
13
|
+
if (!key) {
|
|
14
|
+
return data_store.has(unique_key);
|
|
15
|
+
}
|
|
16
|
+
return !data_store.has(unique_key)
|
|
17
|
+
? false
|
|
18
|
+
: data_store.get(unique_key).has(key);
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CacheStore } from "../../CacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* @description 指定IDのキャッシュを削除する
|
|
4
|
+
* Delete the cache for the specified ID
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @param {string} id
|
|
9
|
+
*/
|
|
10
|
+
export declare const execute: (cache_store: CacheStore, data_store: Map<string, Map<string, any>>, id: string) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { $poolMap } from "../../CacheUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description 指定IDのキャッシュを削除する
|
|
4
|
+
* Delete the cache for the specified ID
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @param {string} id
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (cache_store, data_store, id) => {
|
|
11
|
+
if (!data_store.has(id)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const data = data_store.get(id);
|
|
15
|
+
for (const value of data.values()) {
|
|
16
|
+
cache_store.destroy(value);
|
|
17
|
+
}
|
|
18
|
+
data_store.delete(id);
|
|
19
|
+
$poolMap(data);
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアから指定したキャッシュを削除
|
|
3
|
+
* Remove the specified cache from the cache store
|
|
4
|
+
*
|
|
5
|
+
* @param {Map} data_store
|
|
6
|
+
* @param {string} id
|
|
7
|
+
* @param {string} type
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (data_store: Map<string, Map<string, any>>, id: string, type: string) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { $poolMap } from "../../CacheUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアから指定したキャッシュを削除
|
|
4
|
+
* Remove the specified cache from the cache store
|
|
5
|
+
*
|
|
6
|
+
* @param {Map} data_store
|
|
7
|
+
* @param {string} id
|
|
8
|
+
* @param {string} type
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const execute = (data_store, id, type) => {
|
|
14
|
+
if (!data_store.has(id)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const data = data_store.get(id);
|
|
18
|
+
if (!data.has(type)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// delete key
|
|
22
|
+
data.delete(type);
|
|
23
|
+
if (!data.size) {
|
|
24
|
+
$poolMap(data);
|
|
25
|
+
data_store.delete(id);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CacheStore } from "../../CacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
|
|
4
|
+
* Remove the ID with the deletion flag set by the timer from the cache store
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} trash_store
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (cache_store: CacheStore, trash_store: Map<string, Map<string, any>>) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
|
|
3
|
+
* Remove the ID with the deletion flag set by the timer from the cache store
|
|
4
|
+
*
|
|
5
|
+
* @param {CacheStore} cache_store
|
|
6
|
+
* @param {Map} trash_store
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export const execute = (cache_store, trash_store) => {
|
|
12
|
+
if (!trash_store.size) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for (const [id, data] of trash_store) {
|
|
16
|
+
if (!data.has("trash")) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
cache_store.removeById(id);
|
|
20
|
+
cache_store.$removeIds.push(+id);
|
|
21
|
+
}
|
|
22
|
+
trash_store.clear();
|
|
23
|
+
cache_store.$removeCache = false;
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CacheStore } from "../../CacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアの指定IDの削除フラグを立てる
|
|
4
|
+
* Set the deletion flag of the specified ID in the cache store
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @param {Map} trash_store
|
|
9
|
+
* @param {string} id
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
export declare const execute: (cache_store: CacheStore, data_store: Map<string, Map<string, any>>, trash_store: Map<string, Map<string, any>>, id: string) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュストアの指定IDの削除フラグを立てる
|
|
3
|
+
* Set the deletion flag of the specified ID in the cache store
|
|
4
|
+
*
|
|
5
|
+
* @param {CacheStore} cache_store
|
|
6
|
+
* @param {Map} data_store
|
|
7
|
+
* @param {Map} trash_store
|
|
8
|
+
* @param {string} id
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export const execute = (cache_store, data_store, trash_store, id) => {
|
|
14
|
+
if (trash_store.has(id)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const data = data_store.get(id);
|
|
18
|
+
if (!data) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
data.set("trash", true);
|
|
22
|
+
trash_store.set(id, data);
|
|
23
|
+
if (cache_store.$timerId !== null) {
|
|
24
|
+
clearTimeout(cache_store.$timerId);
|
|
25
|
+
}
|
|
26
|
+
// 1秒後に削除処理を行う
|
|
27
|
+
cache_store.$removeCache = false;
|
|
28
|
+
cache_store.$timerId = setTimeout(() => {
|
|
29
|
+
cache_store.$removeCache = true;
|
|
30
|
+
cache_store.$timerId = null;
|
|
31
|
+
}, 1000);
|
|
32
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CacheStore } from "../../CacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアを全てリセット
|
|
4
|
+
* Reset all cache stores
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (cache_store: CacheStore, data_store: Map<string, Map<string, any>>, trash_store: Map<string, Map<string, any>>) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { $poolMap } from "../../CacheUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアを全てリセット
|
|
4
|
+
* Reset all cache stores
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (cache_store, data_store, trash_store) => {
|
|
13
|
+
// タイマーをクリア
|
|
14
|
+
trash_store.clear();
|
|
15
|
+
if (cache_store.$timerId !== null) {
|
|
16
|
+
clearTimeout(cache_store.$timerId);
|
|
17
|
+
}
|
|
18
|
+
for (const data of data_store.values()) {
|
|
19
|
+
for (const value of data.values()) {
|
|
20
|
+
if (!value) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
cache_store.destroy(value);
|
|
24
|
+
}
|
|
25
|
+
$poolMap(data);
|
|
26
|
+
}
|
|
27
|
+
data_store.clear();
|
|
28
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CacheStore } from "../../CacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアにデータをセット
|
|
4
|
+
* Set data in the cache store
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @param {array} keys
|
|
9
|
+
* @param {*} value
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const execute: (cache_store: CacheStore, data_store: Map<string, Map<string, any>>, unique_key: string, key: string, value?: any) => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { $getMap, $poolMap } from "../../CacheUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャッシュストアにデータをセット
|
|
4
|
+
* Set data in the cache store
|
|
5
|
+
*
|
|
6
|
+
* @param {CacheStore} cache_store
|
|
7
|
+
* @param {Map} data_store
|
|
8
|
+
* @param {array} keys
|
|
9
|
+
* @param {*} value
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export const execute = (cache_store, data_store, unique_key, key, value = null) => {
|
|
15
|
+
// init
|
|
16
|
+
if (!data_store.has(unique_key)) {
|
|
17
|
+
data_store.set(unique_key, $getMap());
|
|
18
|
+
}
|
|
19
|
+
const data = data_store.get(unique_key);
|
|
20
|
+
if (value === null) {
|
|
21
|
+
if (!data.has(key)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
cache_store.destroy(data.get(key));
|
|
25
|
+
data.delete(key);
|
|
26
|
+
if (!data.size) {
|
|
27
|
+
data_store.delete(unique_key);
|
|
28
|
+
$poolMap(data);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// set cache
|
|
33
|
+
data.set(key, value);
|
|
34
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description キャッシュ管理クラス
|
|
3
|
+
* Cache management class
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export declare class CacheStore {
|
|
9
|
+
/**
|
|
10
|
+
* @description キャッシュプール
|
|
11
|
+
* Cache pool
|
|
12
|
+
*
|
|
13
|
+
* @type {HTMLCanvasElement[]}
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
private readonly _$pool;
|
|
17
|
+
/**
|
|
18
|
+
* @description キャッシュストア
|
|
19
|
+
* Cache store
|
|
20
|
+
*
|
|
21
|
+
* @type {Map<string, any>}
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
private readonly _$store;
|
|
25
|
+
/**
|
|
26
|
+
* @description キャッシュトラッシュ
|
|
27
|
+
* Cache trash
|
|
28
|
+
*
|
|
29
|
+
* @type {Map<string, any>}
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
private readonly _$trash;
|
|
33
|
+
/**
|
|
34
|
+
* @description キャッシュ削除用のタイマーID
|
|
35
|
+
* Timer ID for cache deletion
|
|
36
|
+
*
|
|
37
|
+
* @type {NodeJS.Timeout | null}
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
$timerId: NodeJS.Timeout | null;
|
|
41
|
+
/**
|
|
42
|
+
* @description キャッシュタイマーの削除フラグ
|
|
43
|
+
* Deletion flag of cache timer
|
|
44
|
+
*
|
|
45
|
+
* @type {boolean}
|
|
46
|
+
* @default false
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
$removeCache: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @description キャッシュ削除用のIDリスト
|
|
52
|
+
* ID list for cache deletion
|
|
53
|
+
*
|
|
54
|
+
* @type {number[]}
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
readonly $removeIds: number[];
|
|
58
|
+
/**
|
|
59
|
+
* @constructor
|
|
60
|
+
*/
|
|
61
|
+
constructor();
|
|
62
|
+
/**
|
|
63
|
+
* @description 登録された全てのキャッシュをリセット・破棄する
|
|
64
|
+
* Reset and destroy all registered caches
|
|
65
|
+
*
|
|
66
|
+
* @return {void}
|
|
67
|
+
* @method
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
reset(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @description 指定のオブジェクトを破棄する
|
|
73
|
+
* Destroy the specified object
|
|
74
|
+
*
|
|
75
|
+
* @param {object} [object=null]
|
|
76
|
+
* @return {void}
|
|
77
|
+
* @method
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
destroy(object?: any): void;
|
|
81
|
+
/**
|
|
82
|
+
* @description HTMLCanvasElementを返却
|
|
83
|
+
* Returns HTMLCanvasElement
|
|
84
|
+
*
|
|
85
|
+
* @return {HTMLCanvasElement}
|
|
86
|
+
* @method
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
getCanvas(): HTMLCanvasElement;
|
|
90
|
+
/**
|
|
91
|
+
* @description HTMLCanvasElementを再利用する為に、内部配列にプール
|
|
92
|
+
* Pool in an internal array to reuse HTMLCanvasElement
|
|
93
|
+
*
|
|
94
|
+
* @param {string} id
|
|
95
|
+
* @param {string} type
|
|
96
|
+
* @returns {void}
|
|
97
|
+
* @method
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
remove(id: string, type: string): void;
|
|
101
|
+
/**
|
|
102
|
+
* @description 指定IDのキャッシュを削除タイマーに登録
|
|
103
|
+
* Register the cache for the specified ID in the delete timer
|
|
104
|
+
*
|
|
105
|
+
* @param {string} id
|
|
106
|
+
* @returns {void}
|
|
107
|
+
* @method
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
removeTimer(id: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
|
|
113
|
+
* Remove the ID with the deletion flag set by the timer from the cache store
|
|
114
|
+
*
|
|
115
|
+
* @returns {void}
|
|
116
|
+
* @method
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
removeTimerScheduledCache(): void;
|
|
120
|
+
/**
|
|
121
|
+
* @description 指定IDのキャッシュを削除する
|
|
122
|
+
* Delete the cache for the specified ID
|
|
123
|
+
*
|
|
124
|
+
* @param {string} id
|
|
125
|
+
* @returns {void}
|
|
126
|
+
* @method
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
removeById(id: string): void;
|
|
130
|
+
/**
|
|
131
|
+
* @description 指定IDのキャッシュデータを返却
|
|
132
|
+
* Returns the cache data for the specified ID
|
|
133
|
+
*
|
|
134
|
+
* @param {string} id
|
|
135
|
+
* @return {Map<string, any>}
|
|
136
|
+
* @method
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
getById(id: string): Map<string, any>;
|
|
140
|
+
/**
|
|
141
|
+
* @description 指定のキーのキャッシュデータを返却
|
|
142
|
+
* Returns the cache data for the specified key
|
|
143
|
+
*
|
|
144
|
+
* @param {string} unique_key
|
|
145
|
+
* @param {string} key
|
|
146
|
+
* @return {*}
|
|
147
|
+
* @method
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
get(unique_key: string, key: string): any;
|
|
151
|
+
/**
|
|
152
|
+
* @description キャッシュストアにデータをセット
|
|
153
|
+
* Set data in the cache store
|
|
154
|
+
*
|
|
155
|
+
* @param {string} unique_key
|
|
156
|
+
* @param {string} key
|
|
157
|
+
* @param {*} value
|
|
158
|
+
* @return {void}
|
|
159
|
+
* @method
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
set(unique_key: string, key: string, value?: any): void;
|
|
163
|
+
/**
|
|
164
|
+
* @description 指定キーのキャッシュが存在するかどうか
|
|
165
|
+
* Whether the specified key cache exists
|
|
166
|
+
*
|
|
167
|
+
* @param {string} unique_key
|
|
168
|
+
* @param {string} key
|
|
169
|
+
* @return {boolean}
|
|
170
|
+
* @method
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
has(unique_key: string, key?: string): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* @description キャッシュストアのキーを生成
|
|
176
|
+
* Generate cache store keys
|
|
177
|
+
*
|
|
178
|
+
* @param {number} x_scale
|
|
179
|
+
* @param {number} y_scale
|
|
180
|
+
* @param {number} alpha
|
|
181
|
+
* @return {number}
|
|
182
|
+
* @method
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
generateKeys(x_scale: number, y_scale: number, alpha: number): number;
|
|
186
|
+
/**
|
|
187
|
+
* @description フィルター用のキャッシュストアのキーを生成
|
|
188
|
+
* Generate cache store keys for filters
|
|
189
|
+
*
|
|
190
|
+
* @param {number} a
|
|
191
|
+
* @param {number} b
|
|
192
|
+
* @param {number} c
|
|
193
|
+
* @param {number} d
|
|
194
|
+
* @return {string}
|
|
195
|
+
* @method
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
generateFilterKeys(a: number, b: number, c: number, d: number): string;
|
|
199
|
+
}
|
|
200
|
+
export declare const $cacheStore: CacheStore;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { execute as cacheStoreResetService } from "./CacheStore/service/CacheStoreResetService";
|
|
2
|
+
import { execute as cacheStoreDestroyService } from "./CacheStore/service/CacheStoreDestroyService";
|
|
3
|
+
import { execute as cacheStoreRemoveService } from "./CacheStore/service/CacheStoreRemoveService";
|
|
4
|
+
import { execute as cacheStoreRemoveByIdService } from "./CacheStore/service/CacheStoreRemoveByIdService";
|
|
5
|
+
import { execute as cacheStoreGetService } from "./CacheStore/service/CacheStoreGetService";
|
|
6
|
+
import { execute as cacheStoreSetService } from "./CacheStore/service/CacheStoreSetService";
|
|
7
|
+
import { execute as cacheStoreHasService } from "./CacheStore/service/CacheStoreHasService";
|
|
8
|
+
import { execute as cacheStoreGenerateKeysService } from "./CacheStore/service/CacheStoreGenerateKeysService";
|
|
9
|
+
import { execute as cacheStoreGenerateFilterKeysService } from "./CacheStore/service/CacheStoreGenerateFilterKeysService";
|
|
10
|
+
import { execute as cacheStoreRemoveTimerService } from "./CacheStore/service/CacheStoreRemoveTimerService";
|
|
11
|
+
import { execute as cacheStoreRemoveTimerScheduledCacheService } from "./CacheStore/service/CacheStoreRemoveTimerScheduledCacheService";
|
|
12
|
+
/**
|
|
13
|
+
* @description キャッシュ管理クラス
|
|
14
|
+
* Cache management class
|
|
15
|
+
*
|
|
16
|
+
* @class
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
export class CacheStore {
|
|
20
|
+
/**
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
constructor() {
|
|
24
|
+
/**
|
|
25
|
+
* @description キャッシュプール
|
|
26
|
+
* Cache pool
|
|
27
|
+
*
|
|
28
|
+
* @type {HTMLCanvasElement[]}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(this, "_$pool", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* @description キャッシュストア
|
|
39
|
+
* Cache store
|
|
40
|
+
*
|
|
41
|
+
* @type {Map<string, any>}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
Object.defineProperty(this, "_$store", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* @description キャッシュトラッシュ
|
|
52
|
+
* Cache trash
|
|
53
|
+
*
|
|
54
|
+
* @type {Map<string, any>}
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
Object.defineProperty(this, "_$trash", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* @description キャッシュ削除用のタイマーID
|
|
65
|
+
* Timer ID for cache deletion
|
|
66
|
+
*
|
|
67
|
+
* @type {NodeJS.Timeout | null}
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
Object.defineProperty(this, "$timerId", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* @description キャッシュタイマーの削除フラグ
|
|
78
|
+
* Deletion flag of cache timer
|
|
79
|
+
*
|
|
80
|
+
* @type {boolean}
|
|
81
|
+
* @default false
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
Object.defineProperty(this, "$removeCache", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* @description キャッシュ削除用のIDリスト
|
|
92
|
+
* ID list for cache deletion
|
|
93
|
+
*
|
|
94
|
+
* @type {number[]}
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
Object.defineProperty(this, "$removeIds", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
this._$pool = [];
|
|
104
|
+
this._$store = new Map();
|
|
105
|
+
this._$trash = new Map();
|
|
106
|
+
this.$timerId = null;
|
|
107
|
+
this.$removeIds = [];
|
|
108
|
+
this.$removeCache = false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @description 登録された全てのキャッシュをリセット・破棄する
|
|
112
|
+
* Reset and destroy all registered caches
|
|
113
|
+
*
|
|
114
|
+
* @return {void}
|
|
115
|
+
* @method
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
reset() {
|
|
119
|
+
cacheStoreResetService(this, this._$store, this._$trash);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @description 指定のオブジェクトを破棄する
|
|
123
|
+
* Destroy the specified object
|
|
124
|
+
*
|
|
125
|
+
* @param {object} [object=null]
|
|
126
|
+
* @return {void}
|
|
127
|
+
* @method
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
destroy(object = null) {
|
|
131
|
+
cacheStoreDestroyService(this._$pool, object);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @description HTMLCanvasElementを返却
|
|
135
|
+
* Returns HTMLCanvasElement
|
|
136
|
+
*
|
|
137
|
+
* @return {HTMLCanvasElement}
|
|
138
|
+
* @method
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
getCanvas() {
|
|
142
|
+
return this._$pool.pop() || document.createElement("canvas");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @description HTMLCanvasElementを再利用する為に、内部配列にプール
|
|
146
|
+
* Pool in an internal array to reuse HTMLCanvasElement
|
|
147
|
+
*
|
|
148
|
+
* @param {string} id
|
|
149
|
+
* @param {string} type
|
|
150
|
+
* @returns {void}
|
|
151
|
+
* @method
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
remove(id, type) {
|
|
155
|
+
cacheStoreRemoveService(this._$store, id, type);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @description 指定IDのキャッシュを削除タイマーに登録
|
|
159
|
+
* Register the cache for the specified ID in the delete timer
|
|
160
|
+
*
|
|
161
|
+
* @param {string} id
|
|
162
|
+
* @returns {void}
|
|
163
|
+
* @method
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
removeTimer(id) {
|
|
167
|
+
cacheStoreRemoveTimerService(this, this._$store, this._$trash, id);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
|
|
171
|
+
* Remove the ID with the deletion flag set by the timer from the cache store
|
|
172
|
+
*
|
|
173
|
+
* @returns {void}
|
|
174
|
+
* @method
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
removeTimerScheduledCache() {
|
|
178
|
+
cacheStoreRemoveTimerScheduledCacheService(this, this._$trash);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @description 指定IDのキャッシュを削除する
|
|
182
|
+
* Delete the cache for the specified ID
|
|
183
|
+
*
|
|
184
|
+
* @param {string} id
|
|
185
|
+
* @returns {void}
|
|
186
|
+
* @method
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
removeById(id) {
|
|
190
|
+
cacheStoreRemoveByIdService(this, this._$store, id);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @description 指定IDのキャッシュデータを返却
|
|
194
|
+
* Returns the cache data for the specified ID
|
|
195
|
+
*
|
|
196
|
+
* @param {string} id
|
|
197
|
+
* @return {Map<string, any>}
|
|
198
|
+
* @method
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
getById(id) {
|
|
202
|
+
return this._$store.get(id);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @description 指定のキーのキャッシュデータを返却
|
|
206
|
+
* Returns the cache data for the specified key
|
|
207
|
+
*
|
|
208
|
+
* @param {string} unique_key
|
|
209
|
+
* @param {string} key
|
|
210
|
+
* @return {*}
|
|
211
|
+
* @method
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
get(unique_key, key) {
|
|
215
|
+
return cacheStoreGetService(this._$store, unique_key, key);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @description キャッシュストアにデータをセット
|
|
219
|
+
* Set data in the cache store
|
|
220
|
+
*
|
|
221
|
+
* @param {string} unique_key
|
|
222
|
+
* @param {string} key
|
|
223
|
+
* @param {*} value
|
|
224
|
+
* @return {void}
|
|
225
|
+
* @method
|
|
226
|
+
* @public
|
|
227
|
+
*/
|
|
228
|
+
set(unique_key, key, value = null) {
|
|
229
|
+
cacheStoreSetService(this, this._$store, unique_key, key, value);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @description 指定キーのキャッシュが存在するかどうか
|
|
233
|
+
* Whether the specified key cache exists
|
|
234
|
+
*
|
|
235
|
+
* @param {string} unique_key
|
|
236
|
+
* @param {string} key
|
|
237
|
+
* @return {boolean}
|
|
238
|
+
* @method
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
has(unique_key, key = "") {
|
|
242
|
+
return cacheStoreHasService(this._$store, unique_key, key);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @description キャッシュストアのキーを生成
|
|
246
|
+
* Generate cache store keys
|
|
247
|
+
*
|
|
248
|
+
* @param {number} x_scale
|
|
249
|
+
* @param {number} y_scale
|
|
250
|
+
* @param {number} alpha
|
|
251
|
+
* @return {number}
|
|
252
|
+
* @method
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
generateKeys(x_scale, y_scale, alpha) {
|
|
256
|
+
return cacheStoreGenerateKeysService(x_scale, y_scale, alpha);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* @description フィルター用のキャッシュストアのキーを生成
|
|
260
|
+
* Generate cache store keys for filters
|
|
261
|
+
*
|
|
262
|
+
* @param {number} a
|
|
263
|
+
* @param {number} b
|
|
264
|
+
* @param {number} c
|
|
265
|
+
* @param {number} d
|
|
266
|
+
* @return {string}
|
|
267
|
+
* @method
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
generateFilterKeys(a, b, c, d) {
|
|
271
|
+
return cacheStoreGenerateFilterKeysService(a, b, c, d);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
export const $cacheStore = new CacheStore();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 使用済みになったMapオブジェクトをプール
|
|
3
|
+
* Pool Map objects that are no longer in use.
|
|
4
|
+
*
|
|
5
|
+
* @type {Map[]}
|
|
6
|
+
* @const
|
|
7
|
+
* @static
|
|
8
|
+
*/
|
|
9
|
+
export declare const $maps: Map<string, any>[];
|
|
10
|
+
/**
|
|
11
|
+
* @description Mapオブジェクトをプール
|
|
12
|
+
* Pool Map object.
|
|
13
|
+
*
|
|
14
|
+
* @param {Map} map
|
|
15
|
+
* @return void
|
|
16
|
+
* @method
|
|
17
|
+
* @static
|
|
18
|
+
*/
|
|
19
|
+
export declare const $poolMap: (map: Map<string, any>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @description プールしたMapオブジェクト、もしくは新規のMapを返却
|
|
22
|
+
* Returns a pooled Map object or a new Map.
|
|
23
|
+
*
|
|
24
|
+
* @return {Map}
|
|
25
|
+
* @method
|
|
26
|
+
* @static
|
|
27
|
+
*/
|
|
28
|
+
export declare const $getMap: () => Map<string, any>;
|
package/src/CacheUtil.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 使用済みになったMapオブジェクトをプール
|
|
3
|
+
* Pool Map objects that are no longer in use.
|
|
4
|
+
*
|
|
5
|
+
* @type {Map[]}
|
|
6
|
+
* @const
|
|
7
|
+
* @static
|
|
8
|
+
*/
|
|
9
|
+
export const $maps = [];
|
|
10
|
+
/**
|
|
11
|
+
* @description Mapオブジェクトをプール
|
|
12
|
+
* Pool Map object.
|
|
13
|
+
*
|
|
14
|
+
* @param {Map} map
|
|
15
|
+
* @return void
|
|
16
|
+
* @method
|
|
17
|
+
* @static
|
|
18
|
+
*/
|
|
19
|
+
export const $poolMap = (map) => {
|
|
20
|
+
if (map.size) {
|
|
21
|
+
map.clear();
|
|
22
|
+
}
|
|
23
|
+
$maps.push(map);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @description プールしたMapオブジェクト、もしくは新規のMapを返却
|
|
27
|
+
* Returns a pooled Map object or a new Map.
|
|
28
|
+
*
|
|
29
|
+
* @return {Map}
|
|
30
|
+
* @method
|
|
31
|
+
* @static
|
|
32
|
+
*/
|
|
33
|
+
export const $getMap = () => {
|
|
34
|
+
return $maps.pop() || new Map();
|
|
35
|
+
};
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CacheStore";
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CacheStore";
|