infrastructure tier

infrastructure-cache

Caching layer with pluggable backends (Redis, memory, PostgreSQL)

Caching layer with pluggable backends (Redis, memory, PostgreSQL)

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/cache
Edition2021
Targetsinfrastructure_cache
Public items12 across 1 module
Tests8

What it is for

Caching layer with pluggable backends (Redis, memory).

Capabilities

crate root

Caching layer with pluggable backends (Redis, memory).

Item
pub const DEFAULT_TTL: Duration

MemoryCache

In-memory cache backend using DashMap.

Item
pub struct MemoryCache
MemoryCache :: fn default() -> Self
MemoryCache :: fn new() -> Self
MemoryCache :: fn len(& self) -> usize
MemoryCache :: fn is_empty(& self) -> bool
MemoryCache :: async fn get <T : DeserializeOwned + Send>(& self, key : & str) -> Result <Option <T>, CacheError>
MemoryCache :: async fn set <T : Serialize + Send + Sync>(& self, key : & str, value : & T, ttl : Option <Duration>,) -> Result <(), CacheError>
MemoryCache :: async fn delete(& self, key : & str) -> Result <(), CacheError>
MemoryCache :: async fn exists(& self, key : & str) -> Result <bool, CacheError>
MemoryCache :: async fn clear(& self) -> Result <(), CacheError>
MemoryCache :: async fn get_or_set <T, F, Fut>(& self, key : & str, ttl : Option <Duration>, f : F,) -> Result <T, CacheError> where T : Serialize + DeserializeOwned + Send + Sync, F : FnOnce() -> Fut + Send, Fut : Future <Output = Result <T, CacheError>> + Send,

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

infrastructure_cache

Public surface

`crate root`

ItemWhat it is
pub const DEFAULT_TTL: DurationDefault TTL for cache entries (1 hour).

`memory`

ItemWhat it is
pub struct MemoryCacheIn-memory cache backed by DashMap
MemoryCache :: fn default() -> Self
MemoryCache :: fn new() -> SelfCreates a new empty memory cache.
MemoryCache :: fn len(& self) -> usizeReturns the number of entries in the cache
MemoryCache :: fn is_empty(& self) -> boolReturns true if the cache is empty.
MemoryCache :: async fn get <T : DeserializeOwned + Send>(& self, key : & str) -> Result <Option <T>, CacheError>
MemoryCache :: async fn set <T : Serialize + Send + Sync>(& self, key : & str, value : & T, ttl : Option <Duration>,) -> Result <(), CacheError>
MemoryCache :: async fn delete(& self, key : & str) -> Result <(), CacheError>
MemoryCache :: async fn exists(& self, key : & str) -> Result <bool, CacheError>
MemoryCache :: async fn clear(& self) -> Result <(), CacheError>
MemoryCache :: async fn get_or_set <T, F, Fut>(& self, key : & str, ttl : Option <Duration>, f : F,) -> Result <T, CacheError> where T : Serialize + DeserializeOwned + Send + Sync, F : FnOnce() -> Fut + Send, Fut : Future <Output = Result <T, CacheError>> + Send,

Re-exports. Exported here, defined elsewhere.

ExportDefined in
CacheBackendbackend::CacheBackend
CacheErrorerror::CacheError
MemoryCachememory::MemoryCache

Boundary

Reaches into foundation.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/cache
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_infrastructure["infrastructure"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
chrono^0.4serdenoalways
dashmap^6noalways
redis^0.27tokio-compyesalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1fullnoalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_cache["application-cache"] -->|uses| SELF
  SELF["infrastructure-cache"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
defaultyes
redisdep:redisno
flowchart LR
  n_default["default"]
  n_redis["redis"] --> n_dep_redis["dep:redis"]

Targets

KindNameSource
libinfrastructure_cache`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: application-cache.

Verification

KindCount
Unit tests8
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root100
memory101

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc512
Public modules with a //! block11
pie showData
    title Public items with rustdoc
    "Documented" : 5
    "No rustdoc detected" : 7

Metrics

MetricValue
Rust source files4
Source lines420
Code lines272
Public API items12
Public modules1
Tests8
Examples0
Cargo features2
Direct runtime dependencies11
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 1
    "method" : 10
    "struct" : 1
pie showData
    title Rust source composition
    "Code" : 272
    "Blank or comment" : 148

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All infrastructure · Manual