Repository navigation
feature(cache): caching API - #636
Merged
Merged
Conversation
Kuba663
reviewed
Oct 10, 2026
Kuba663
left a comment
Collaborator
There was a problem hiding this comment.
Mostly just there to be there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track the proposal here: #627
Summary
This proposal + PR adds a file cache in the
com.cleanroommc.cleanroom.cachepackage for downloaded, bundled and generated files.An entry is fetched once, verified by SHA-256 on every access, kept across restarts, and served offline once cached.
Usage
API
Cacheinstance(),global(),namespace(String),root(),fromUrl,fromResource,fromFile,fromString,fromBytes,fromBufferCacheRequestexpectSha256,version,revalidateIf,get,put,getAsync,putAsyncCacheExceptionkind()returnsOFFLINE,HASH_MISMATCH,HTTPorUNSAFE_PATHgetingests only when the entry is missing, corrupt, outdated, or expected with another hash.putalways ingests from the source.Behaviour
Integrity
expectSha256is enforced. Without one, the first ingested hash is pinned.getre-hashes the stored file.Confinement
..escapes are rejected..meta,.lockand.versionssuffixes are reserved on every path segment.Versioning
version(String)re-ingests when the requested version is greater, compared with Forge'sComparableVersion.OFFLINE, naming the cached and the required version.Web
HttpClientwith redirects, a 10s connect timeout, and a 30s timeout for response headers and for each body read.revalidateIf(Duration)serves the cached entry and revalidates it in the background with a conditional GET (ETag,Last-Modified).OFFLINE. It never leaves an empty file.Concurrency
<name>.lockfor other processes.gets of one entry share a single download.Filesystem Layout
System Properties
cleanroom.cache.root.instance<gameDir>/.cleanroom/cachecleanroom.cache.root.global~/.cleanroom/cachecleanroom.offlinefalsecleanroom.cache.timeout30(seconds)