Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Experimental in-memory files cache with eviction policy support #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 3, 2024

Conversation

joseluisq
Copy link
Collaborator

@joseluisq joseluisq commented Mar 7, 2024

Description

This PR adds support for in-memory cache functionality on-read to SWS via an advanced configuration entry.

The feature also supports expiration policies such as Time To Live (TTL) and Time To Idle (TTI).

Admission to a cache is controlled by the Least Frequently Used (LFU) policy and the eviction from a cache is controlled by the Least Recently Used (LRU) policy.

For details about the options supported, see the cache library docs.

Configuration example:

[general]

[advanced]

[advanced.memory-cache]
# Maximum capacity entries of the memory cache-store. Default 256
capacity = 256
# Time to live in seconds of a cached file entry. Default 1h
ttl = 3600
# Time to idle in seconds of a cached file entry. Default 5min
tti = 300
# Maximum size in bytes for a file entry to be cached. Default 8MB
max-file-size = 8192

Note that this feature requires Rust 1.76.0 or newer.

Also, point out that this experimental feature could be subject to change in future releases.

Library usage

This work was added as part of the Cargo experimental feature. See #482.

Related Issue

Motivation and Context

Resolves #242

How Has This Been Tested?

Screenshots (if appropriate):

@joseluisq joseluisq added enhancement New feature or request v2 v2 release PoC This is only a proof of concept labels Mar 7, 2024
@joseluisq joseluisq self-assigned this Mar 7, 2024
Copy link

semanticdiff-com bot commented Mar 7, 2024

Review changes with SemanticDiff.

Analyzed 13 of 20 files.

Overall, the semantic diff is 10% smaller than the GitHub diff.

Filename Status
Cargo.lock Unsupported file format
Cargo.toml Unsupported file format
✔️ tests/compression_static.rs Analyzed
✔️ tests/dir_listing.rs Analyzed
✔️ tests/static_files.rs Analyzed
tests/toml/config.toml Unsupported file format
✔️ src/cors.rs Analyzed
✔️ src/handler.rs 33.33% smaller
✔️ src/lib.rs Analyzed
✔️ src/response.rs 7.44% smaller
✔️ src/server.rs 57.56% smaller
✔️ src/static_files.rs 24.7% smaller
✔️ src/testing.rs Analyzed
✔️ src/settings/file.rs Analyzed
✔️ src/settings/mod.rs 0.44% smaller
src/mem_cache/cache.rs Unsupported file format
✔️ src/mem_cache/mod.rs Analyzed
src/mem_cache/stream.rs Unsupported file format
docs/content/building-from-source.md Unsupported file format
.github/workflows/devel.yml Unsupported file format

@joseluisq joseluisq force-pushed the memory-cache-support branch from cd1cc6e to 61daaac Compare March 11, 2024 00:06
@joseluisq joseluisq changed the title In-memory files cache with eviction policy support In-memory files cache with eviction policy and TTL support Mar 15, 2024
@joseluisq joseluisq removed the PoC This is only a proof of concept label Apr 5, 2024
@joseluisq joseluisq force-pushed the memory-cache-support branch from 635316b to 5b224db Compare April 6, 2024 19:20
@joseluisq joseluisq added the advanced-feature Advanced feature only available via the configuration file label Apr 6, 2024
@joseluisq joseluisq added the PoC This is only a proof of concept label May 1, 2024
@joseluisq joseluisq force-pushed the master branch 3 times, most recently from 69668a6 to 936b224 Compare May 19, 2024 00:10
@joseluisq joseluisq force-pushed the memory-cache-support branch from c14666a to 51e9c0a Compare May 22, 2024 04:21
@joseluisq joseluisq changed the title In-memory files cache with eviction policy and TTL support In-memory files cache with eviction policy support Aug 23, 2024
@joseluisq joseluisq added experimental This is an experimental feature and removed PoC This is only a proof of concept labels Aug 23, 2024
@joseluisq joseluisq force-pushed the memory-cache-support branch from 8a2f55e to fc4fe29 Compare August 31, 2024 21:59
@joseluisq joseluisq marked this pull request as ready for review September 3, 2024 21:40
@joseluisq joseluisq changed the title In-memory files cache with eviction policy support Experimental in-memory files cache with eviction policy support Sep 3, 2024
@joseluisq joseluisq merged commit 5bdfcd4 into master Sep 3, 2024
35 checks passed
@joseluisq joseluisq deleted the memory-cache-support branch September 3, 2024 22:15
@joseluisq joseluisq added this to the v2.33.0 milestone Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced-feature Advanced feature only available via the configuration file enhancement New feature or request experimental This is an experimental feature v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add in memory cache to SWS
1 participant