@next2d/cache 3.2.1 → 3.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/cache",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "Next2D Cache Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @description 指定IDの削除タイマー登録を取り消す
3
+ * Cancel the deletion timer registration for the specified ID
4
+ *
5
+ * 削除タイマー(trash_store)に登録済みのエントリを再利用する場合に呼ぶ。
6
+ * これにより、1秒後の removeTimerScheduledCache() による wipe を防ぐ。
7
+ * 主にステージから一旦外れたインスタンスが addedToStage で再復帰した際の
8
+ * キャッシュ復活経路として使用する。
9
+ * When reusing an entry that has been registered for removal in the trash_store,
10
+ * this is called to prevent the wipe by removeTimerScheduledCache() after 1 second.
11
+ *
12
+ * @param {Map} data_store
13
+ * @param {Map} trash_store
14
+ * @param {string} id
15
+ * @return {void}
16
+ * @method
17
+ * @public
18
+ */
19
+ export declare const execute: (data_store: Map<string, Map<string, any>>, trash_store: Map<string, Map<string, any>>, id: string) => void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @description 指定IDの削除タイマー登録を取り消す
3
+ * Cancel the deletion timer registration for the specified ID
4
+ *
5
+ * 削除タイマー(trash_store)に登録済みのエントリを再利用する場合に呼ぶ。
6
+ * これにより、1秒後の removeTimerScheduledCache() による wipe を防ぐ。
7
+ * 主にステージから一旦外れたインスタンスが addedToStage で再復帰した際の
8
+ * キャッシュ復活経路として使用する。
9
+ * When reusing an entry that has been registered for removal in the trash_store,
10
+ * this is called to prevent the wipe by removeTimerScheduledCache() after 1 second.
11
+ *
12
+ * @param {Map} data_store
13
+ * @param {Map} trash_store
14
+ * @param {string} id
15
+ * @return {void}
16
+ * @method
17
+ * @public
18
+ */
19
+ export const execute = (data_store, trash_store, id) => {
20
+ if (!trash_store.has(id)) {
21
+ return;
22
+ }
23
+ trash_store.delete(id);
24
+ const data = data_store.get(id);
25
+ if (data) {
26
+ data.delete("trash");
27
+ }
28
+ };
@@ -2,11 +2,20 @@
2
2
  * @description 指定のキーからデータを取得
3
3
  * Get data from the specified key
4
4
  *
5
+ * 削除予定(trash_store 登録済み)のエントリは get 時に削除予定をキャンセルする。
6
+ * これにより、get 後の removeTimerScheduledCache() で
7
+ * 内側 Map の "trash" マーク削除によりループがスキップされる問題を回避する。
8
+ * When entries are pending deletion (registered in trash_store), the
9
+ * scheduled removal is canceled here. This prevents the
10
+ * removeTimerScheduledCache() loop from skipping such entries due to
11
+ * the inner Map's "trash" marker having been deleted.
12
+ *
5
13
  * @param {Map} data_store
14
+ * @param {Map} trash_store
6
15
  * @param {string} unique_key
7
16
  * @param {string} key
8
17
  * @return {*}
9
18
  * @method
10
- * @public
11
- */
12
- export declare const execute: (data_store: Map<string, Map<string, any>>, unique_key: string, key: string) => any;
19
+ * @public
20
+ */
21
+ export declare const execute: (data_store: Map<string, Map<string, any>>, trash_store: Map<string, Map<string, any>>, unique_key: string, key: string) => any;
@@ -2,18 +2,30 @@
2
2
  * @description 指定のキーからデータを取得
3
3
  * Get data from the specified key
4
4
  *
5
+ * 削除予定(trash_store 登録済み)のエントリは get 時に削除予定をキャンセルする。
6
+ * これにより、get 後の removeTimerScheduledCache() で
7
+ * 内側 Map の "trash" マーク削除によりループがスキップされる問題を回避する。
8
+ * When entries are pending deletion (registered in trash_store), the
9
+ * scheduled removal is canceled here. This prevents the
10
+ * removeTimerScheduledCache() loop from skipping such entries due to
11
+ * the inner Map's "trash" marker having been deleted.
12
+ *
5
13
  * @param {Map} data_store
14
+ * @param {Map} trash_store
6
15
  * @param {string} unique_key
7
16
  * @param {string} key
8
17
  * @return {*}
9
18
  * @method
10
- * @public
11
- */
12
- export const execute = (data_store, unique_key, key) => {
19
+ * @public
20
+ */
21
+ export const execute = (data_store, trash_store, unique_key, key) => {
13
22
  const data = data_store.get(unique_key) || null;
14
23
  if (!data) {
15
24
  return null;
16
25
  }
17
- data.delete("trash");
26
+ if (trash_store.has(unique_key)) {
27
+ trash_store.delete(unique_key);
28
+ data.delete("trash");
29
+ }
18
30
  return data.get(key) || null;
19
31
  };
@@ -108,6 +108,16 @@ export declare class CacheStore {
108
108
  * @public
109
109
  */
110
110
  removeTimer(id: string): void;
111
+ /**
112
+ * @description 指定IDの削除タイマー登録を取り消す(再利用時に呼ぶ)
113
+ * Cancel the deletion timer registration for the specified ID (call on reuse)
114
+ *
115
+ * @param {string} id
116
+ * @returns {void}
117
+ * @method
118
+ * @public
119
+ */
120
+ cancelRemoveTimer(id: string): void;
111
121
  /**
112
122
  * @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
113
123
  * Remove the ID with the deletion flag set by the timer from the cache store
package/src/CacheStore.js CHANGED
@@ -9,6 +9,7 @@ import { execute as cacheStoreGenerateKeysService } from "./CacheStore/service/C
9
9
  import { execute as cacheStoreGenerateFilterKeysService } from "./CacheStore/service/CacheStoreGenerateFilterKeysService";
10
10
  import { execute as cacheStoreRemoveTimerService } from "./CacheStore/service/CacheStoreRemoveTimerService";
11
11
  import { execute as cacheStoreRemoveTimerScheduledCacheService } from "./CacheStore/service/CacheStoreRemoveTimerScheduledCacheService";
12
+ import { execute as cacheStoreCancelRemoveTimerService } from "./CacheStore/service/CacheStoreCancelRemoveTimerService";
12
13
  /**
13
14
  * @description キャッシュ管理クラス
14
15
  * Cache management class
@@ -166,6 +167,18 @@ export class CacheStore {
166
167
  removeTimer(id) {
167
168
  cacheStoreRemoveTimerService(this, this._$store, this._$trash, id);
168
169
  }
170
+ /**
171
+ * @description 指定IDの削除タイマー登録を取り消す(再利用時に呼ぶ)
172
+ * Cancel the deletion timer registration for the specified ID (call on reuse)
173
+ *
174
+ * @param {string} id
175
+ * @returns {void}
176
+ * @method
177
+ * @public
178
+ */
179
+ cancelRemoveTimer(id) {
180
+ cacheStoreCancelRemoveTimerService(this._$store, this._$trash, id);
181
+ }
169
182
  /**
170
183
  * @description タイマーでセットされた削除フラグを持つIDをキャッシュストアから削除する
171
184
  * Remove the ID with the deletion flag set by the timer from the cache store
@@ -212,7 +225,7 @@ export class CacheStore {
212
225
  * @public
213
226
  */
214
227
  get(unique_key, key) {
215
- return cacheStoreGetService(this._$store, unique_key, key);
228
+ return cacheStoreGetService(this._$store, this._$trash, unique_key, key);
216
229
  }
217
230
  /**
218
231
  * @description キャッシュストアにデータをセット