Skip to content

Commit

Permalink
tarantool: fix missing key delete
Browse files Browse the repository at this point in the history
  • Loading branch information
lowitea committed Aug 13, 2023
1 parent 6903355 commit 991e20f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hitbox-tarantool/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ impl CacheBackend for TarantoolBackend {
.map_err(|err| BackendError::InternalError(Box::new(err)))?;
let result = response
.decode_result_set::<(String, Option<u32>, String)>()
.map(|_| Some(DeleteStatus::Deleted(1)))
.map_err(|err| BackendError::InternalError(Box::new(err)))?
.unwrap_or(DeleteStatus::Missing);
Ok(result)
.map_err(|err| BackendError::InternalError(Box::new(err)))?;

if result.is_empty() {
Ok(DeleteStatus::Missing)
} else {
Ok(DeleteStatus::Deleted(1))
}
}

async fn set<T>(
Expand Down
3 changes: 3 additions & 0 deletions hitbox-tarantool/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ async fn test_delete() {
let value = r#"{"data":{"a":42,"b":"nope"},"expired":"2012-12-12T12:12:12Z"}"#.to_string();
let ttl = 42;

let status = t.backend.delete(key.clone()).await.unwrap();
assert_eq!(status, DeleteStatus::Missing);

t.call::<_, (String, Option<u32>, String)>(
"box.space.hitbox_cache:replace",
&("test_key".to_string(), ttl, value),
Expand Down

0 comments on commit 991e20f

Please sign in to comment.