Allow cacheKey to be overridden on get method

Created on 25 September 2023, over 1 year ago
Updated 20 June 2024, 6 months ago

Problem/Motivation

The POC cache implementation uses a default cache key that makes sense for default JSON:API - entityTypeId--bundleId. Allowing a different cache key strategy seems like it could be useful and it would also make it possible to use the store in some creative ways.

Proposed resolution

* In the JsonApiClient GetOptions interface, add a cacheKey property.
* Update the JsonApiClient createCacheKey method to also accept a cacheKey option. If this is provided, return the provided cache key string. (This might feel a little strange, but this approach will open up possibilities for anyone who is extending the class and overriding the createCacheKey method)
* In the JsonApiClient, update all calls to createCacheKey to pass the cacheKey option if provided.

* In the DecoupledRouterClient GetOptions interface, add a cacheKey property.
* Update the DecoupledRouterClient createCacheKey method to also accept a cacheKey option. If this is provided, return the provided cache key string. (This might feel a little strange, but this approach will open up possibilities for anyone who is extending the class and overriding the createCacheKey method)
* In the DecoupledRouterClient, update all calls to createCacheKey to pass the cacheKey option if provided.

Remaining tasks

* Implement changes in JsonApiClient
* Implement changes in DecoupledRouterClient
* Add test coverage
* Update documentation

API changes

* a cacheKey property will be added to the GetOptions interface for JsonApiClient and DecoupledRouterClient

✨ Feature request
Status

Fixed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brianperry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024