aws_secretsmanager_cache/lib.rs
1// Apache License
2
3// Copyright (c) 2021 Adam Quigley
4
5//! This crate provides a client for in-process caching of secrets from AWS Secrets Manager for Rust applications.
6//! It is heavily inspired by the [AWS Secrets Manager Go Caching Client](https://github.com/aws/aws-secretsmanager-caching-go)
7//! and the [AWS SDK for Rust](https://github.com/awslabs/aws-sdk-rust).
8//!
9//! The client internally uses an LRU (least-recently used) caching scheme that provides
10//! O(1) insertions and O(1) lookups for cached values.
11
12//! ## Example
13//! ```rust
14//! use aws_sdk_secretsmanager::Client;
15//! use aws_secretsmanager_cache::SecretCache;
16//!
17//! #[tokio::main]
18//! async fn main() {
19//! let aws_config = aws_config::from_env().load().await;
20//! let client = Client::new(&aws_config);
21//! let mut cache = SecretCache::new(client);
22//!
23//! let secret_id = "service/secret";
24//!
25//! match cache.get_secret_string(secret_id.to_string()).send().await {
26//! Ok(secret_value) => {
27//! // do something
28//! }
29//! Err(e) => println!("{}", e),
30//! }
31//! }
32//! ```
33
34mod cache;
35mod cache_item;
36mod config;
37pub use cache::SecretCache;
38pub use config::CacheConfig;