Skip to content
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
7 changes: 6 additions & 1 deletion crates/ember-core/src/keyspace/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ impl Keyspace {
/// If the field doesn't exist, it is created with the increment as its value.
/// The stored value must be a valid float or the call returns an error.
/// Returns the new value as a formatted string.
pub fn hincrbyfloat(&mut self, key: &str, field: &str, delta: f64) -> Result<String, IncrFloatError> {
pub fn hincrbyfloat(
&mut self,
key: &str,
field: &str,
delta: f64,
) -> Result<String, IncrFloatError> {
self.remove_if_expired(key);

let is_new = match self.entries.get(key) {
Expand Down
14 changes: 8 additions & 6 deletions crates/ember-core/src/shard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2059,12 +2059,14 @@ fn dispatch(
Err(_) => ShardResponse::WrongType,
},
ShardRequest::HIncrBy { key, field, delta } => incr_result(ks.hincrby(key, field, *delta)),
ShardRequest::HIncrByFloat { key, field, delta } => match ks.hincrbyfloat(key, field, *delta) {
Ok(val) => ShardResponse::BulkString(val),
Err(IncrFloatError::WrongType) => ShardResponse::WrongType,
Err(IncrFloatError::OutOfMemory) => ShardResponse::OutOfMemory,
Err(e) => ShardResponse::Err(e.to_string()),
},
ShardRequest::HIncrByFloat { key, field, delta } => {
match ks.hincrbyfloat(key, field, *delta) {
Ok(val) => ShardResponse::BulkString(val),
Err(IncrFloatError::WrongType) => ShardResponse::WrongType,
Err(IncrFloatError::OutOfMemory) => ShardResponse::OutOfMemory,
Err(e) => ShardResponse::Err(e.to_string()),
}
}
ShardRequest::HKeys { key } => match ks.hkeys(key) {
Ok(keys) => ShardResponse::StringArray(keys),
Err(_) => ShardResponse::WrongType,
Expand Down
Loading
Loading