[package]
edition = "2024"
rust-version = "1.92"
name = "cached"
version = "3.1.0"
authors = ["James Kominick <james@kominick.com>"]
build = false
exclude = [
".agents/",
".claude/",
".github/",
"bin/",
"docs/dev/",
"specs/",
"local/",
".cursorrules",
"AGENTS.md",
"CLAUDE.md",
"Makefile",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Generic cache implementations and simplified function memoization"
documentation = "https://docs.rs/cached"
readme = "README.md"
keywords = [
"cache",
"memoize",
"lru",
"redis",
"disk",
]
categories = [
"caching",
"data-structures",
]
license = "MIT"
repository = "https://github.com/jaemk/cached"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
]
[features]
ahash = [
"dep:ahash",
"hashbrown/default",
]
async = [
"async_core",
"dep:async-lock",
]
async_core = []
default = [
"proc_macro",
"ahash",
"time_stores",
]
proc_macro = [
"dep:cached_proc_macro",
"dep:cached_proc_macro_types",
]
redb_store = [
"dep:serde",
"dep:rmp-serde",
"dep:redb",
"dep:directories",
"dep:blocking",
]
redis_async_cache = [
"redis_store",
"async",
"redis/cache-aio",
]
redis_connection_manager = [
"redis_store",
"async",
"redis/connection-manager",
]
redis_smol = [
"redis_store",
"async",
"redis/smol-comp",
]
redis_smol_native_tls = [
"redis_smol",
"redis/smol-native-tls-comp",
]
redis_smol_rustls = [
"redis_smol",
"redis/smol-rustls-comp",
]
redis_store = [
"dep:serde",
"dep:rmp-serde",
"dep:redis",
"dep:r2d2",
"dep:serde_json",
]
redis_tokio = [
"redis_store",
"async",
"redis/tokio-comp",
]
redis_tokio_native_tls = [
"redis_tokio",
"redis/tokio-native-tls-comp",
]
redis_tokio_rustls = [
"redis_tokio",
"redis/tokio-rustls-comp",
]
time_stores = []
[lib]
name = "cached"
path = "src/lib.rs"
[[example]]
name = "async_std"
path = "examples/async_std.rs"
required-features = [
"async",
"proc_macro",
]
[[example]]
name = "basic"
path = "examples/basic.rs"
required-features = [
"time_stores",
"proc_macro",
]
[[example]]
name = "disk"
path = "examples/disk.rs"
required-features = [
"redb_store",
"proc_macro",
]
[[example]]
name = "disk_async"
path = "examples/disk_async.rs"
required-features = [
"redb_store",
"async",
"proc_macro",
]
[[example]]
name = "expires_per_key"
path = "examples/expires_per_key.rs"
required-features = ["proc_macro"]
[[example]]
name = "expiring_sized_cache"
path = "examples/expiring_sized_cache.rs"
required-features = ["time_stores"]
[[example]]
name = "kitchen_sink"
path = "examples/kitchen_sink.rs"
required-features = [
"time_stores",
"proc_macro",
]
[[example]]
name = "redis"
path = "examples/redis.rs"
required-features = [
"redis_store",
"proc_macro",
]
[[example]]
name = "redis-async-async-std"
path = "examples/redis-async-async-std.rs"
required-features = [
"redis_smol_native_tls",
"proc_macro",
]
[[example]]
name = "redis-async-tokio"
path = "examples/redis-async-tokio.rs"
required-features = [
"redis_tokio_native_tls",
"proc_macro",
]
[[example]]
name = "redis-client-side-cache-tokio"
path = "examples/redis-client-side-cache-tokio.rs"
required-features = [
"redis_async_cache",
"redis_tokio_native_tls",
"proc_macro",
]
[[example]]
name = "refresh_before_expiry"
path = "examples/refresh_before_expiry.rs"
required-features = [
"time_stores",
"proc_macro",
"async",
]
[[example]]
name = "resilience"
path = "examples/resilience.rs"
required-features = [
"time_stores",
"proc_macro",
]
[[example]]
name = "sharded"
path = "examples/sharded.rs"
required-features = [
"time_stores",
"proc_macro",
]
[[example]]
name = "sharded_expiring"
path = "examples/sharded_expiring.rs"
required-features = ["proc_macro"]
[[example]]
name = "stale_while_revalidate"
path = "examples/stale_while_revalidate.rs"
required-features = [
"time_stores",
"proc_macro",
"async",
]
[[example]]
name = "struct_method"
path = "examples/struct_method.rs"
required-features = ["proc_macro"]
[[example]]
name = "tokio"
path = "examples/tokio.rs"
required-features = [
"async",
"proc_macro",
]
[[test]]
name = "builder_hasher_slot_parity"
path = "tests/builder_hasher_slot_parity.rs"
[[test]]
name = "cached"
path = "tests/cached.rs"
[[test]]
name = "companions_optout"
path = "tests/companions_optout.rs"
[[test]]
name = "concurrent_cached_async_ext"
path = "tests/concurrent_cached_async_ext.rs"
[[test]]
name = "concurrent_cached_fallback_expires"
path = "tests/concurrent_cached_fallback_expires.rs"
[[test]]
name = "frozen_format_golden"
path = "tests/frozen_format_golden.rs"
[[test]]
name = "name_raw_ident"
path = "tests/name_raw_ident.rs"
[[test]]
name = "once_g1_positive"
path = "tests/once_g1_positive.rs"
[[test]]
name = "proc_macro_path_alias"
path = "tests/proc_macro_path_alias.rs"
[[test]]
name = "proc_macro_v3_ui"
path = "tests/proc_macro_v3_ui.rs"
[[test]]
name = "refresh_on_hit_split"
path = "tests/refresh_on_hit_split.rs"
[[test]]
name = "release_scripts"
path = "tests/release_scripts.rs"
[[test]]
name = "serialize_set_dispatch"
path = "tests/serialize_set_dispatch.rs"
[[test]]
name = "sharded_hasher_accepts_buildhasher"
path = "tests/sharded_hasher_accepts_buildhasher.rs"
[[test]]
name = "sharded_try_set_max_size_overflow"
path = "tests/sharded_try_set_max_size_overflow.rs"
[[test]]
name = "v3_additive_parity"
path = "tests/v3_additive_parity.rs"
[[test]]
name = "v3_async_setref_notsync_dispatch"
path = "tests/v3_async_setref_notsync_dispatch.rs"
[[test]]
name = "v3_builder_new_parity"
path = "tests/v3_builder_new_parity.rs"
[[test]]
name = "v3_cache_peek_with_expiry_status"
path = "tests/v3_cache_peek_with_expiry_status.rs"
[[test]]
name = "v3_cache_value_ergonomics"
path = "tests/v3_cache_value_ergonomics.rs"
[[test]]
name = "v3_cert_expiring_lru_key_lifecycle"
path = "tests/v3_cert_expiring_lru_key_lifecycle.rs"
[[test]]
name = "v3_cert_expiring_lru_lru_ttl_parity"
path = "tests/v3_cert_expiring_lru_lru_ttl_parity.rs"
[[test]]
name = "v3_cert_expiring_lru_stored_key"
path = "tests/v3_cert_expiring_lru_stored_key.rs"
[[test]]
name = "v3_cert_lru_ttl_perf"
path = "tests/v3_cert_lru_ttl_perf.rs"
[[test]]
name = "v3_cert_sharded_lru_clock_sample"
path = "tests/v3_cert_sharded_lru_clock_sample.rs"
[[test]]
name = "v3_cert_sharded_lru_concurrency"
path = "tests/v3_cert_sharded_lru_concurrency.rs"
[[test]]
name = "v3_cert_sharded_lru_semantics"
path = "tests/v3_cert_sharded_lru_semantics.rs"
[[test]]
name = "v3_companions_optout_coverage"
path = "tests/v3_companions_optout_coverage.rs"
[[test]]
name = "v3_concurrent_evictions_agg"
path = "tests/v3_concurrent_evictions_agg.rs"
[[test]]
name = "v3_concurrent_peek_async"
path = "tests/v3_concurrent_peek_async.rs"
[[test]]
name = "v3_contains_dyn_dispatch"
path = "tests/v3_contains_dyn_dispatch.rs"
[[test]]
name = "v3_contains_parity"
path = "tests/v3_contains_parity.rs"
[[test]]
name = "v3_custom_hasher_threaded"
path = "tests/v3_custom_hasher_threaded.rs"
[[test]]
name = "v3_error_debug_redaction"
path = "tests/v3_error_debug_redaction.rs"
[[test]]
name = "v3_evict_key"
path = "tests/v3_evict_key.rs"
[[test]]
name = "v3_expiring_evict_order"
path = "tests/v3_expiring_evict_order.rs"
[[test]]
name = "v3_expiring_lru_on_evict_key"
path = "tests/v3_expiring_lru_on_evict_key.rs"
[[test]]
name = "v3_expiring_lru_order"
path = "tests/v3_expiring_lru_order.rs"
[[test]]
name = "v3_force_refresh"
path = "tests/v3_force_refresh.rs"
[[test]]
name = "v3_inmemory_panic_safety"
path = "tests/v3_inmemory_panic_safety.rs"
[[test]]
name = "v3_io_error_display"
path = "tests/v3_io_error_display.rs"
[[test]]
name = "v3_keyed_cache_private"
path = "tests/v3_keyed_cache_private.rs"
[[test]]
name = "v3_macros"
path = "tests/v3_macros.rs"
[[test]]
name = "v3_macros_ui"
path = "tests/v3_macros_ui.rs"
[[test]]
name = "v3_metrics_unknown"
path = "tests/v3_metrics_unknown.rs"
[[test]]
name = "v3_per_entry_expiry"
path = "tests/v3_per_entry_expiry.rs"
[[test]]
name = "v3_per_key_expiry_read"
path = "tests/v3_per_key_expiry_read.rs"
[[test]]
name = "v3_prime_and_attrs"
path = "tests/v3_prime_and_attrs.rs"
[[test]]
name = "v3_redb_builder"
path = "tests/v3_redb_builder.rs"
[[test]]
name = "v3_redb_corrupt_file"
path = "tests/v3_redb_corrupt_file.rs"
[[test]]
name = "v3_redb_races"
path = "tests/v3_redb_races.rs"
[[test]]
name = "v3_redb_races_async"
path = "tests/v3_redb_races_async.rs"
[[test]]
name = "v3_redb_set_expired_previous"
path = "tests/v3_redb_set_expired_previous.rs"
[[test]]
name = "v3_redis_backward_read"
path = "tests/v3_redis_backward_read.rs"
[[test]]
name = "v3_redis_binary_key_clear"
path = "tests/v3_redis_binary_key_clear.rs"
[[test]]
name = "v3_redis_cache_set_ref"
path = "tests/v3_redis_cache_set_ref.rs"
[[test]]
name = "v3_redis_key_escaping_coverage"
path = "tests/v3_redis_key_escaping_coverage.rs"
[[test]]
name = "v3_redis_selfheal"
path = "tests/v3_redis_selfheal.rs"
[[test]]
name = "v3_redis_ttl_optional"
path = "tests/v3_redis_ttl_optional.rs"
[[test]]
name = "v3_redis_ttl_validation"
path = "tests/v3_redis_ttl_validation.rs"
[[test]]
name = "v3_result_fallback_race"
path = "tests/v3_result_fallback_race.rs"
[[test]]
name = "v3_retain_sharded_lru"
path = "tests/v3_retain_sharded_lru.rs"
[[test]]
name = "v3_retain_sharded_map"
path = "tests/v3_retain_sharded_map.rs"
[[test]]
name = "v3_retain_ttl_sorted"
path = "tests/v3_retain_ttl_sorted.rs"
[[test]]
name = "v3_serialize_set"
path = "tests/v3_serialize_set.rs"
[[test]]
name = "v3_sharded_builder"
path = "tests/v3_sharded_builder.rs"
[[test]]
name = "v3_sharded_collapse_coverage"
path = "tests/v3_sharded_collapse_coverage.rs"
[[test]]
name = "v3_sharded_concurrent_expiry"
path = "tests/v3_sharded_concurrent_expiry.rs"
[[test]]
name = "v3_sharded_copy_from_err"
path = "tests/v3_sharded_copy_from_err.rs"
[[test]]
name = "v3_sharded_expiring_set_single_eval"
path = "tests/v3_sharded_expiring_set_single_eval.rs"
[[test]]
name = "v3_sharded_hasher_type_param"
path = "tests/v3_sharded_hasher_type_param.rs"
[[test]]
name = "v3_sharded_lru_read_path"
path = "tests/v3_sharded_lru_read_path.rs"
[[test]]
name = "v3_sharded_on_evict_key_parity"
path = "tests/v3_sharded_on_evict_key_parity.rs"
[[test]]
name = "v3_sharded_resize"
path = "tests/v3_sharded_resize.rs"
[[test]]
name = "v3_sharded_retain_no_key_clone"
path = "tests/v3_sharded_retain_no_key_clone.rs"
[[test]]
name = "v3_sharded_retain_panic_safety"
path = "tests/v3_sharded_retain_panic_safety.rs"
[[test]]
name = "v3_sharded_zero_ttl"
path = "tests/v3_sharded_zero_ttl.rs"
[[test]]
name = "v3_single_owner_zero_ttl"
path = "tests/v3_single_owner_zero_ttl.rs"
[[test]]
name = "v3_traits"
path = "tests/v3_traits.rs"
[[test]]
name = "v3_ttl_sorted_fixes"
path = "tests/v3_ttl_sorted_fixes.rs"
[[test]]
name = "v3_ttl_sorted_panic_safety"
path = "tests/v3_ttl_sorted_panic_safety.rs"
[[test]]
name = "v3_ttl_sorted_set_with"
path = "tests/v3_ttl_sorted_set_with.rs"
[[test]]
name = "v3_ui_async_guard"
path = "tests/v3_ui_async_guard.rs"
[[bench]]
name = "cache_benches"
path = "benches/cache_benches.rs"
harness = false
required-features = [
"time_stores",
"proc_macro",
]
[dependencies.ahash]
version = "0.8"
optional = true
default-features = false
[dependencies.async-lock]
version = "3"
optional = true
[dependencies.blocking]
version = "1"
optional = true
[dependencies.cached_proc_macro]
version = "3.0.0"
optional = true
[dependencies.cached_proc_macro_types]
version = "3.0.0"
optional = true
[dependencies.directories]
version = "6.0"
optional = true
[dependencies.hashbrown]
version = "0.17"
features = ["inline-more"]
default-features = false
[dependencies.parking_lot]
version = "0.12.5"
[dependencies.r2d2]
version = "0.8"
optional = true
[dependencies.redb]
version = "4"
optional = true
[dependencies.redis]
version = "1.0"
features = ["r2d2"]
optional = true
[dependencies.rmp-serde]
version = "1.1"
optional = true
[dependencies.serde]
version = "1.0"
features = ["derive"]
optional = true
[dependencies.serde_json]
version = "1"
optional = true
[dependencies.thiserror]
version = "2"
[dependencies.web-time]
version = "^1.1.0"
[dev-dependencies.async-std]
version = "1.6"
features = ["attributes"]
[dev-dependencies.criterion]
version = "0.8"
[dev-dependencies.futures]
version = "0.3"
[dev-dependencies.googletest]
version = "0.14"
[dev-dependencies.serial_test]
version = "3"
[dev-dependencies.smartstring]
version = "1"
[dev-dependencies.tempfile]
version = "3.10.1"
[dev-dependencies.tokio]
version = "1"
features = [
"macros",
"time",
"sync",
"parking_lot",
"rt",
"rt-multi-thread",
]
[dev-dependencies.trybuild]
version = "1"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.ahash]
version = "0.8"
features = ["runtime-rng"]
optional = true
default-features = false