Skip to content
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

feat: add get/set to CacheClient to support readme.ts example #185

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ edition = "2021"
[workspace]

[dependencies]
momento = "0.15.0"
tokio = { version = "1.18.2", features = ["full"] }
#momento = "0.15.0"
momento = { path = "../" }
tokio = { version = "1.18.2", features = ["full"] }
3 changes: 3 additions & 0 deletions example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use momento::simple_cache_client::SimpleCacheClientBuilder;
use std::env;
use std::num::NonZeroU64;
use std::process;
use std::time::Duration;
use momento::{CacheClient, CredentialProvider};
use momento::config::configurations::laptop;

#[tokio::main]
async fn main() {
Expand Down
27 changes: 25 additions & 2 deletions example/src/readme.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
pub fn main() {
// TODO: add example code here
use std::time::Duration;
use momento::{CacheClient, CredentialProvider};
use momento::config::configurations::laptop;

const CACHE_NAME: String = "cache";

pub async fn main() {
let cache_client = CacheClient::new(
CredentialProvider::from_env_var("MOMENTO_API_KEY")?,
laptop::latest(),
Duration::from_secs(60)
)?;

cache_client.create_cache(CACHE_NAME).await?;

match(cache_client.set(CACHE_NAME, "mykey", "myvalue").await) {
Ok(_) => println!("Successfully stored key 'mykey' with value 'myvalue'"),
Err(e) => println!("Error: {}", e)
}

let value = match(cache_client.get(CACHE_NAME, "mykey").await?) {

};


}
Loading
Loading