-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the momento sdk to the latest version
- Loading branch information
Showing
31 changed files
with
343 additions
and
245 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,57 @@ | ||
use super::*; | ||
|
||
use ::momento::cache::{CollectionTtl, DictionarySetFieldRequest, DictionarySetFieldsRequest}; | ||
|
||
/// Set the value for a field in a hash (dictionary). | ||
/// | ||
/// NOTE: if a TTL is specified, this command will not refresh the TTL for the | ||
/// collection. | ||
pub async fn hash_set( | ||
client: &mut SimpleCacheClient, | ||
client: &mut CacheClient, | ||
config: &Config, | ||
cache_name: &str, | ||
request: workload::client::HashSet, | ||
) -> std::result::Result<(), ResponseError> { | ||
if request.data.is_empty() { | ||
panic!("empty data for hash set"); | ||
} | ||
|
||
HASH_SET.increment(); | ||
let data: HashMap<Vec<u8>, Vec<u8>> = request | ||
.data | ||
.iter() | ||
.map(|(k, v)| (k.to_vec(), v.to_vec())) | ||
.collect(); | ||
let result = timeout( | ||
config.client().unwrap().request_timeout(), | ||
client.dictionary_set( | ||
|
||
if request.data.len() == 1 { | ||
let (field, value) = request.data.into_iter().next().unwrap(); | ||
|
||
let r = DictionarySetFieldRequest::new( | ||
cache_name, | ||
&*request.key, | ||
data, | ||
CollectionTtl::new(request.ttl, false), | ||
), | ||
) | ||
.await; | ||
record_result!(result, HASH_SET) | ||
&*field, | ||
value, | ||
) | ||
.ttl(CollectionTtl::new(request.ttl, false)); | ||
|
||
let result = timeout( | ||
config.client().unwrap().request_timeout(), | ||
client.send_request(r), | ||
) | ||
.await; | ||
|
||
record_result!(result, HASH_SET) | ||
} else { | ||
let d: Vec<(Vec<u8>, Vec<u8>)> = request | ||
.data | ||
.into_iter() | ||
.map(|(k, v)| (k.to_vec(), v)) | ||
.collect(); | ||
|
||
let r = DictionarySetFieldsRequest::new(cache_name, &*request.key, d) | ||
.ttl(CollectionTtl::new(request.ttl, false)); | ||
|
||
let result = timeout( | ||
config.client().unwrap().request_timeout(), | ||
client.send_request(r), | ||
) | ||
.await; | ||
|
||
record_result!(result, HASH_SET) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.