Skip to content

Docs: Document the LruCache Utility API #680

Description

@nathanschmid08

Category

Documentation

Description

The framework includes a built-in Least Recently Used (LRU) Cache implementation located in lib/core/utils/LruCache.js. This utility is used internally (e.g., for page keep-alive caching) and is exported for general use. However, it is completely undocumented in the utility reference guide (docs/src/content/docs/api-reference/utils.md).

Proposed Solution

Update docs/src/content/docs/api-reference/utils.md to document the LruCache API:

  • Document the constructor signature: new LruCache(limit, onEvict).
  • List and explain all public methods and properties:
    • get(key): retrieves a cached item and updates its recency.
    • set(key, value): inserts/updates a cached item, evicting the LRU item if the limit is exceeded.
    • has(key): checks key existence without updating recency.
    • delete(key): removes a key.
    • clear(): clears the cache.
    • size: getter for current size.
  • Provide a clear code example showing instantiation, caching operations, and handling the onEvict callback.

Acceptance Criteria

  • The LruCache API reference is added to docs/src/content/docs/api-reference/utils.md.
  • All public properties and methods are documented with parameters and return types.
  • A functional code example demonstrating the cache lifecycle and eviction callback is included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions