You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-24Lines changed: 6 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -314,42 +314,24 @@ If a platform needs to use a separate library (like using MMVK for react-native)
314
314
315
315
[Docs](./API.md)
316
316
317
-
# Cache Eviction
317
+
# Storage Eviction
318
318
319
319
Different platforms come with varying storage capacities and Onyx has a way to gracefully fail when those storage limits are encountered. When Onyx fails to set or modify a key the following steps are taken:
320
-
1. Onyx looks at a list of recently accessed keys (access is defined as subscribed to or modified) and locates the key that was least recently accessed
321
-
2. It then deletes this key and retries the original operation
320
+
1. Onyx looks at a list of evictable keys ordered by recent access and locates the least recently accessed one
321
+
2. It then deletes this key from both cache and storage, and retries the original operation
322
+
3. This process repeats up to 5 times until the write succeeds or no more evictable keys are available
322
323
323
324
By default, Onyx will not evict anything from storage and will presume all keys are "unsafe" to remove unless explicitly told otherwise.
324
325
325
-
**To flag a key as safe for removal:**
326
-
- Add the key to the `evictableKeys` option in `Onyx.init(options)`
327
-
- Implement `canEvict` in the Onyx config for each component subscribing to a key
328
-
- The key will only be deleted when all subscribers return `true` for `canEvict`
326
+
**To flag a key as safe for removal**, add the key to the `evictableKeys` option in `Onyx.init(options)`:
Only individual (non-collection) keys matching the `evictableKeys` patterns will be considered for eviction. Collection keys themselves cannot be evicted — only their individual members can.
* @param [shouldReindexCache] – This is an LRU cache, and by default accessing a value will make it become last in line to be evicted. This flag can be used to skip that and just access the value directly without side-effects.
0 commit comments