@firecms/core 3.0.0-canary.286 → 3.0.0-canary.287

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.
@@ -82,9 +82,6 @@ function customReviver(key: string, value: any): any {
82
82
  * @param data - The data to cache and persist.
83
83
  */
84
84
  export function saveEntityToCache(path: string, data: object): void {
85
- // Update the in-memory cache
86
- entityCache.set(path, data);
87
-
88
85
  // Persist the data individually in localStorage
89
86
  if (isLocalStorageAvailable) {
90
87
  try {
@@ -100,6 +97,22 @@ export function saveEntityToCache(path: string, data: object): void {
100
97
  }
101
98
  }
102
99
 
100
+ export function removeEntityFromMemoryCache(path: string): void {
101
+ entityCache.delete(path);
102
+ }
103
+
104
+ export function saveEntityToMemoryCache(path: string, data: object): void {
105
+ entityCache.set(path, data);
106
+ }
107
+
108
+ export function getEntityFromMemoryCache(path: string): object | undefined {
109
+ return entityCache.get(path);
110
+ }
111
+
112
+ export function hasEntityInCache(path: string): boolean {
113
+ return entityCache.has(path);
114
+ }
115
+
103
116
  /**
104
117
  * Retrieves an entity from the in-memory cache or `localStorage`.
105
118
  * If the entity is not in the cache but exists in `localStorage`, it loads it into the cache.
@@ -107,21 +120,15 @@ export function saveEntityToCache(path: string, data: object): void {
107
120
  * @param useLocalStorage
108
121
  * @returns The cached entity or `undefined` if not found.
109
122
  */
110
- export function getEntityFromCache(path: string, useLocalStorage = true): object | undefined {
111
-
112
- // Attempt to retrieve the entity from the in-memory cache
113
- if (entityCache.has(path)) {
114
- return entityCache.get(path);
115
- }
123
+ export function getEntityFromCache(path: string): object | undefined {
116
124
 
117
125
  // If not in the cache, attempt to load it from localStorage
118
- if (isLocalStorageAvailable && useLocalStorage) {
126
+ if (isLocalStorageAvailable) {
119
127
  try {
120
128
  const key = LOCAL_STORAGE_PREFIX + path;
121
129
  const entityString = localStorage.getItem(key);
122
130
  if (entityString) {
123
131
  const entity: object = JSON.parse(entityString, customReviver);
124
- entityCache.set(path, entity); // Update the cache
125
132
  return entity;
126
133
  }
127
134
  } catch (error) {
@@ -136,22 +143,11 @@ export function getEntityFromCache(path: string, useLocalStorage = true): object
136
143
  return undefined;
137
144
  }
138
145
 
139
- export function hasEntityInCache(path: string): boolean {
140
- return entityCache.has(path);
141
- }
142
-
143
146
  /**
144
147
  * Removes an entity from both the in-memory cache and `localStorage`.
145
148
  * @param path - The unique path/key for the entity to remove.
146
149
  */
147
150
  export function removeEntityFromCache(path: string): void {
148
-
149
- console.debug("Removing entity from cache", path);
150
-
151
- // Remove from the in-memory cache
152
- entityCache.delete(path);
153
-
154
- // Remove from localStorage
155
151
  if (isLocalStorageAvailable) {
156
152
  try {
157
153
  const key = LOCAL_STORAGE_PREFIX + path;