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

Add endpoint to read values from KV #177

Closed
wants to merge 1 commit into from
Closed

Add endpoint to read values from KV #177

wants to merge 1 commit into from

Conversation

caass
Copy link
Contributor

@caass caass commented Mar 16, 2022

The motivation here is to backport cloudflare/workers-sdk#587, so we need to be able to read KV values so that we can re-upload them with a TTL.

There is some issue here in that the expiration on a KV pair is sent back as a response header, which as far as I can tell we don't have a way to incorporate into this library. Would love it though if it were possible to deserialize the TTL from the response header!

Draft for now since I still need to test if this actually works, but serde_json supports deserializing raw strings:

fn main() {
    let hello: String = serde_json::from_str("\"hello\"").unwrap();
    println!("{hello}")
}
   Compiling json-string v0.1.0 (/Users/cass/Projects/work/json-string)
    Finished dev [unoptimized + debuginfo] target(s) in 1.22s
     Running `target/debug/json-string`
hello

The API Docs indicate that KV just returns a raw string, so...it should work? But I'm going to test it out before marking this PR as ready for review.

@Noah-Kennedy Noah-Kennedy self-requested a review March 16, 2022 16:04
@Noah-Kennedy
Copy link
Collaborator

@caass you also need to fix some clippy lints

@caass
Copy link
Contributor Author

caass commented Mar 16, 2022

Ah it was too good to be true anyway, I can't seem to make it work.

@caass caass closed this Mar 16, 2022
@Noah-Kennedy
Copy link
Collaborator

Ah, sad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants