Skip to content

Commit

Permalink
feat: allow changing builder default ttl (#43)
Browse files Browse the repository at this point in the history
Allow the `SimpleCacheClientBuilder` default ttl to be modified by
adding a new function. This is necessary if we want to be able to
create several clients with different ttls after initializing the
builder.

For example, this is desirable in the proxy where we want to allow
a different ttl for each cache but use the same underlying grpc
channels.
  • Loading branch information
brayniac authored Apr 12, 2022
1 parent c6fb9c7 commit 215c80d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/simple_cache_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ impl SimpleCacheClientBuilder {
}
}

pub fn default_ttl_seconds(mut self, seconds: NonZeroU64) -> Result<Self, MomentoError> {
utils::is_ttl_valid(&seconds)?;
self.default_ttl_seconds = seconds;
Ok(self)
}

pub fn build(self) -> SimpleCacheClient {
let control_interceptor = InterceptedService::new(
self.control_channel,
Expand Down

0 comments on commit 215c80d

Please sign in to comment.