-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating defrag and tests to use cursors and make test more robust by…
… getting hits Signed-off-by: zackcam <[email protected]>
- Loading branch information
Showing
4 changed files
with
159 additions
and
182 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::os::raw::{c_ulong, c_void}; | ||
|
||
use valkey_module::raw; | ||
|
||
pub struct Defrag { | ||
pub defrag_ctx: *mut raw::RedisModuleDefragCtx, | ||
} | ||
|
||
impl Defrag { | ||
pub const fn new(defrag_ctx: *mut raw::RedisModuleDefragCtx) -> Self { | ||
Self { defrag_ctx } | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// This function should not be called before the horsemen are ready. | ||
pub unsafe fn alloc(&self, ptr: *mut c_void) -> *mut c_void { | ||
unsafe { raw::RedisModule_DefragAlloc.unwrap()(self.defrag_ctx, ptr) } | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// This function should not be called before the horsemen are ready. | ||
pub unsafe fn curserset(&self, cursor: u64) -> i32 { | ||
unsafe { raw::RedisModule_DefragCursorSet.unwrap()(self.defrag_ctx, cursor) } | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// This function should not be called before the horsemen are ready. | ||
pub unsafe fn curserget(&self, cursor: *mut u64) -> i32 { | ||
unsafe { raw::RedisModule_DefragCursorGet.unwrap()(self.defrag_ctx, cursor) } | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// This function should not be called before the horsemen are ready. | ||
pub unsafe fn should_stop_defrag(&self) -> i32 { | ||
unsafe { raw::RedisModule_DefragShouldStop.unwrap()(self.defrag_ctx) } | ||
} | ||
} |
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 +1,2 @@ | ||
pub mod bloom_callback; | ||
pub mod defrag; |
Oops, something went wrong.