Skip to content

Introduce SimpleKeyMappingCache and ContainerKeySimpleCache - #8150

Merged
labkey-adam merged 6 commits into
developfrom
fb_key_mapping_cache
Oct 9, 2026
Merged

labkey-adam merged 6 commits into
developfrom
fb_key_mapping_cache

Conversation

@labkey-adam

@labkey-adam labkey-adam commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Using Container objects as cache keys can be very expensive, especially on servers with a large number of containers and workbooks. We want to cache using each container's GUID instead of the Container object itself. See analysis here: #8134

Changes

The above referenced PR and companion PRs switch every Container-keyed cache to a GUID-keyed cache. Each cache then implements new get/put/remove and other behaviors that map Containers to GUID and back, as needed.

This PR takes a different approach. Cache factory methods now optionally receive the cache key's class. In the case of a Container key, the factory returns a special cache whose methods take Containers but whose underlying cache uses GUID keys. Passing in Container.class is the only change needed to switch to this more efficient cache.

SimpleKeyMappingCache implements the five critical cache methods, mapping keys using the passed in Functions. This general-purpose class can be used to map any cache key to a more efficient alternative. CacheManager has a registry that maps key classes to specialized caches that can be a SimpleKeyMappingCache (or some other specialized implementation).

ContainerKeySimpleCache is a one-line class that extends SimpleKeyMappingCache and provides the simple Container <-> GUID mapping functions.

Tasks

  • Claude Code Review
  • Test Automation - junit tests added

@labkey-adam
labkey-adam merged commit a63b928 into develop Oct 9, 2026
8 checks passed
@labkey-adam
labkey-adam deleted the fb_key_mapping_cache branch October 9, 2026 17:15
labkey-adam added a commit to LabKey/customModules that referenced this pull request Oct 9, 2026
## Rationale
Using Containers as cache keys is safe again (and convenient)

## Related Pull Requests
- LabKey/platform#8150
labkey-adam added a commit to LabKey/targetedms that referenced this pull request Oct 9, 2026
## Rationale
Using Containers as cache keys is safe again (and convenient)

## Related Pull Requests
- LabKey/platform#8150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants