diff --git a/.github/release-drafter-config.yml b/.github/release-drafter-config.yml deleted file mode 100644 index 0eb1ee38..00000000 --- a/.github/release-drafter-config.yml +++ /dev/null @@ -1,21 +0,0 @@ -name-template: 'Version $NEXT_PATCH_VERSION' -tag-template: 'v$NEXT_PATCH_VERSION' -categories: - - title: 'Features' - labels: - - 'feature' - - 'enhancement' - - title: 'Bug Fixes' - labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: 'Maintenance' - label: 'chore' -change-template: '- $TITLE (#$NUMBER)' -exclude-labels: - - 'skip-changelog' -template: | - ## Changes - - $CHANGES diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0afbe23..95d443ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,23 +3,9 @@ name: CI on: [pull_request] jobs: - get-nightly-version: - runs-on: ubuntu-latest - outputs: - nightly-version: ${{ steps.get-nightly.outputs.version }} - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Get nightly version from rust-toolchain.toml - id: get-nightly - run: | - NIGHTLY_VERSION=$(grep 'channel = ' rust-toolchain.toml | sed 's/.*"\(.*\)".*/\1/') - echo "version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT - test: name: Build and run the unit tests using the latest rust. runs-on: ${{ matrix.os }} - needs: get-nightly-version strategy: fail-fast: false matrix: @@ -33,35 +19,34 @@ jobs: - [7-2, "7.2"] toolchain: - stable - - ${{ needs.get-nightly-version.outputs.nightly-version }} steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: - submodules: recursive + submodules: recursive - name: Checkout redis sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: - submodules: recursive - repository: redis/redis - ref: ${{ matrix.redis-version[1] }} - path: redis + submodules: recursive + repository: redis/redis + ref: ${{ matrix.redis-version[1] }} + path: redis - name: Install redis run: | - export HOMEBREW_NO_AUTO_UPDATE=1 - cd redis - make -j - ./src/redis-server --version - make install PREFIX=/usr/local - redis-server --version + export HOMEBREW_NO_AUTO_UPDATE=1 + cd redis + make -j + ./src/redis-server --version + make install PREFIX=/usr/local + redis-server --version - name: Setup python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: "3.10" - name: Install Clang (for bindgen) run: | @@ -78,26 +63,16 @@ jobs: - name: Install toolchain id: tc - uses: dtolnay/rust-toolchain@master + uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: ${{ matrix.toolchain }} components: rustfmt, clippy - - name: Setup cache - if: runner.os != 'macOS' - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-test-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }} - - name: Format run: cargo fmt --all -- --check - name: Clippy - run: cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }},bindgen-runtime + run: cargo clippy --workspace --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }},bindgen-runtime - name: Build debug run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }},bindgen-runtime diff --git a/.github/workflows/cratesio-publish.yml b/.github/workflows/cratesio-publish.yml deleted file mode 100644 index fff7c395..00000000 --- a/.github/workflows/cratesio-publish.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Cratesio Publish -on: - release: - types: [published] - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - - name: get version from tag - id: get_version - run: | - realversion="${GITHUB_REF/refs\/tags\//}" - realversion="${realversion//v/}" - echo "VERSION=$realversion" >> $GITHUB_OUTPUT - - - name: Set the version for publishing - uses: ciiiii/toml-editor@1.0.0 - with: - file: "Cargo.toml" - key: "package.version" - value: "${{ steps.get_version.outputs.VERSION }}" - - - name: Set the version for redismodule-rs-macros-internals - uses: ciiiii/toml-editor@1.0.0 - with: - file: "Cargo.toml" - key: "dependencies.redis-module-macros-internals" - value: "${{ steps.get_version.outputs.VERSION }}" - - - name: Set the version for publishing on macros crate - uses: ciiiii/toml-editor@1.0.0 - with: - file: "redismodule-rs-macros/Cargo.toml" - key: "package.version" - value: "${{ steps.get_version.outputs.VERSION }}" - - - name: Set the version for publishing on internal macros crate - uses: ciiiii/toml-editor@1.0.0 - with: - file: "redismodule-rs-macros-internals/Cargo.toml" - key: "package.version" - value: "${{ steps.get_version.outputs.VERSION }}" - - - name: Publishing redismodule-rs-macros-internals - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - path: './redismodule-rs-macros-internals' - args: --allow-dirty - - - name: Publishing redismodule-rs - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - args: --allow-dirty - - - name: Publishing redismodule-rs-macros - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - path: './redismodule-rs-macros' - args: --allow-dirty diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml deleted file mode 100644 index caac3ca1..00000000 --- a/.github/workflows/release-drafter.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Release Drafter - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - master - -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 - with: - # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml - config-name: release-drafter-config.yml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml new file mode 100644 index 00000000..4dd51dff --- /dev/null +++ b/.github/workflows/release-pr.yml @@ -0,0 +1,32 @@ +name: Open a release PR + +on: + workflow_dispatch: # Manual trigger only + +jobs: + # Create a PR with the new versions and changelog, preparing the next release. + # A release will be automatically published when the PR is merged into master. + release-pr: + name: Open a release PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: recursive + fetch-depth: 0 + persist-credentials: false + - name: Install toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..07b68561 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release-plz + +on: + push: + branches: + - master + +jobs: + # Release unpublished packages if the latest commit merged + # a release PR into master + release: + name: Publish a new release to crates.io + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: recursive + fetch-depth: 0 + persist-credentials: false + - name: Install toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-registry-token.yml b/.github/workflows/test-registry-token.yml deleted file mode 100644 index 37d642cc..00000000 --- a/.github/workflows/test-registry-token.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Test Registry Token - -on: - workflow_dispatch: # Manual trigger only - -jobs: - test-token: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Test registry token login - run: | - echo "Testing cargo login with registry token..." - # Use environment variable to avoid any risk of token exposure - echo "$CARGO_REGISTRY_TOKEN" | cargo login - echo "✅ Registry token login successful" - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 1e079d72..abb4a64e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,19 @@ +[workspace] +members = [".", "redismodule-rs-macros", "redismodule-rs-macros-internals"] + +[workspace.package] +version = "2.0.7" +license = "BSD-3-Clause" +edition = "2021" + [package] name = "redis-module" -version = "99.99.99" +version.workspace = true +edition.workspace = true +license.workspace = true authors = ["Gavrie Philipson ", "Guy Korland "] -edition = "2021" build = "build.rs" description = "A toolkit for building Redis modules in Rust" -license = "BSD-3-Clause" repository = "https://github.com/RedisLabsModules/redismodule-rs" readme = "README.md" keywords = ["redis", "plugin"] @@ -151,6 +159,7 @@ cc = "1" default = ["min-redis-compatibility-version-6-0", "bindgen-runtime"] # xor having minimum compatibility version +min-redis-compatibility-version-8-0 = ["redis-module/min-redis-compatibility-version-8-0"] min-redis-compatibility-version-7-4 = ["redis-module/min-redis-compatibility-version-7-4"] min-redis-compatibility-version-7-2 = ["redis-module/min-redis-compatibility-version-7-2"] min-redis-compatibility-version-7-0 = ["redis-module/min-redis-compatibility-version-7-0"] diff --git a/README.md b/README.md index 1e93af1a..220b2caa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Releases](https://img.shields.io/github/release/RedisLabsModules/redismodule-rs.svg)](https://github.com/RedisLabsModules/redismodule-rs/releases/latest) [![crates.io](https://img.shields.io/crates/v/redis-module.svg)](https://crates.io/crates/redis-module) [![docs](https://docs.rs/redis-module/badge.svg)](https://docs.rs/redis-module) -[![CircleCI](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master.svg?style=svg)](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master) # redismodule-rs diff --git a/build.sh b/build.sh index a678407d..29d81105 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ #!/usr/bin/env sh -cargo build --all --all-targets --no-default-features --features min-redis-compatibility-version-7-4 +cargo build --all --all-targets --no-default-features --features min-redis-compatibility-version-8-0 diff --git a/examples/call.rs b/examples/call.rs index 3e4633aa..c3dc6a08 100644 --- a/examples/call.rs +++ b/examples/call.rs @@ -113,7 +113,7 @@ fn call_test(ctx: &Context, _: Vec) -> RedisResult { Ok("pass".into()) } -fn call_blocking_internal(ctx: &Context) -> PromiseCallReply { +fn call_blocking_internal(ctx: &Context) -> PromiseCallReply<'_, '_> { let call_options = CallOptionsBuilder::new().build_blocking(); ctx.call_blocking("blpop", &call_options, &["list", "1"]) } diff --git a/examples/info_handler_macro.rs b/examples/info_handler_macro.rs index fb38023c..e57e1a61 100644 --- a/examples/info_handler_macro.rs +++ b/examples/info_handler_macro.rs @@ -1,11 +1,14 @@ +use redis_module::InfoContext; use redis_module::{redis_module, RedisResult}; -use redis_module::{InfoContext, Status}; use redis_module_macros::info_command_handler; #[info_command_handler] fn add_info(ctx: &InfoContext, _for_crash_report: bool) -> RedisResult<()> { - if ctx.add_info_section(Some("info")) == Status::Ok { - ctx.add_info_field_str("field", "value"); + if let Ok(section) = ctx.builder().add_section("info").field("field", "value") { + let Ok(section) = section.build_section() else { + return Ok(()); + }; + let _ = section.build_info(); } Ok(()) diff --git a/examples/info_handler_multiple_sections.rs b/examples/info_handler_multiple_sections.rs index cd9dd5b3..4ef80ac5 100644 --- a/examples/info_handler_multiple_sections.rs +++ b/examples/info_handler_multiple_sections.rs @@ -17,7 +17,7 @@ fn add_info(ctx: &InfoContext, _for_crash_report: bool) -> RedisResult<()> { let data = InfoSection1 { field_1: "value1".to_owned(), }; - let _ = ctx.build_one_section(data)?; + ctx.build_one_section(data)?; let data = InfoSection2 { field_2: "value2".to_owned(), diff --git a/examples/keys_pos.rs b/examples/keys_pos.rs index cfefb36c..524f4ec0 100644 --- a/examples/keys_pos.rs +++ b/examples/keys_pos.rs @@ -2,7 +2,7 @@ use redis_module::{redis_module, Context, RedisError, RedisResult, RedisString, fn keys_pos(ctx: &Context, args: Vec) -> RedisResult { // Number of args (excluding command name) must be even - if (args.len() - 1) % 2 != 0 { + if !(args.len() - 1).is_multiple_of(2) { return Err(RedisError::WrongArity); } diff --git a/examples/load_unload.rs b/examples/load_unload.rs index 86f7787a..b225a037 100644 --- a/examples/load_unload.rs +++ b/examples/load_unload.rs @@ -1,14 +1,14 @@ +use std::sync::Mutex; + use redis_module::{logging::RedisLogLevel, redis_module, Context, RedisString, Status}; -static mut GLOBAL_STATE: Option = None; +static GLOBAL_STATE: Mutex> = Mutex::new(None); fn init(ctx: &Context, args: &[RedisString]) -> Status { - let (before, after) = unsafe { - let before = GLOBAL_STATE.clone(); - GLOBAL_STATE.replace(format!("Args passed: {}", args.join(", "))); - let after = GLOBAL_STATE.clone(); - (before, after) - }; + let mut state = GLOBAL_STATE.lock().unwrap(); + let before = state.clone(); + *state = Some(format!("Args passed: {}", args.join(", "))); + let after = state.clone(); ctx.log( RedisLogLevel::Warning, &format!("Update global state on LOAD. BEFORE: {before:?}, AFTER: {after:?}",), @@ -18,11 +18,9 @@ fn init(ctx: &Context, args: &[RedisString]) -> Status { } fn deinit(ctx: &Context) -> Status { - let (before, after) = unsafe { - let before = GLOBAL_STATE.take(); - let after = GLOBAL_STATE.clone(); - (before, after) - }; + let mut state = GLOBAL_STATE.lock().unwrap(); + let before = state.take(); + let after = state.clone(); ctx.log( RedisLogLevel::Warning, &format!("Update global state on UNLOAD. BEFORE: {before:?}, AFTER: {after:?}"), diff --git a/examples/test_helper.rs b/examples/test_helper.rs index d8692432..0aff6604 100644 --- a/examples/test_helper.rs +++ b/examples/test_helper.rs @@ -1,5 +1,5 @@ +use redis_module::InfoContext; use redis_module::{redis_module, Context, RedisError, RedisResult, RedisString}; -use redis_module::{InfoContext, Status}; fn test_helper_version(ctx: &Context, _args: Vec) -> RedisResult { let ver = ctx.get_redis_version()?; @@ -20,7 +20,7 @@ fn test_helper_command_name(ctx: &Context, _args: Vec) -> RedisResu } fn test_helper_err(ctx: &Context, args: Vec) -> RedisResult { - if args.len() < 1 { + if args.is_empty() { return Err(RedisError::WrongArity); } @@ -31,8 +31,15 @@ fn test_helper_err(ctx: &Context, args: Vec) -> RedisResult { } fn add_info(ctx: &InfoContext, _for_crash_report: bool) { - if ctx.add_info_section(Some("test_helper")) == Status::Ok { - ctx.add_info_field_str("field", "value"); + if let Ok(section) = ctx + .builder() + .add_section("test_helper") + .field("field", "value") + { + let Ok(section) = section.build_section() else { + return; + }; + let _ = section.build_info(); } } diff --git a/examples/timer.rs b/examples/timer.rs index 6c3904f3..0ea1237f 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -14,7 +14,7 @@ fn timer_create(ctx: &Context, args: Vec) -> RedisResult { let timer_id = ctx.create_timer(Duration::from_millis(duration as u64), callback, data); - return Ok(format!("{}", timer_id).into()); + Ok(format!("{}", timer_id).into()) } fn timer_info(ctx: &Context, args: Vec) -> RedisResult { diff --git a/redismodule-rs-macros-internals/Cargo.toml b/redismodule-rs-macros-internals/Cargo.toml index 7e175e57..7429dd33 100644 --- a/redismodule-rs-macros-internals/Cargo.toml +++ b/redismodule-rs-macros-internals/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "redis-module-macros-internals" -version = "99.99.99" authors = ["Meir Shpilraien "] -edition = "2021" description = "A macros crate for redismodule-rs" -license = "BSD-3-Clause" +version.workspace = true +edition.workspace = true +license.workspace = true repository = "https://github.com/RedisLabsModules/redismodule-rs" keywords = ["redis", "plugin"] categories = ["database", "api-bindings"] diff --git a/redismodule-rs-macros-internals/src/api_versions.rs b/redismodule-rs-macros-internals/src/api_versions.rs index 012ef104..f4ba38de 100644 --- a/redismodule-rs-macros-internals/src/api_versions.rs +++ b/redismodule-rs-macros-internals/src/api_versions.rs @@ -32,6 +32,7 @@ lazy_static::lazy_static! { (70000, "min-redis-compatibility-version-7-0".to_string()), (70200, "min-redis-compatibility-version-7-2".to_string()), (70400, "min-redis-compatibility-version-7-4".to_string()), + (80000, "min-redis-compatibility-version-8-0".to_string()), ]; } diff --git a/redismodule-rs-macros/Cargo.toml b/redismodule-rs-macros/Cargo.toml index c5eec4c6..be486d89 100644 --- a/redismodule-rs-macros/Cargo.toml +++ b/redismodule-rs-macros/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "redis-module-macros" -version = "99.99.99" +version.workspace = true +edition.workspace = true +license.workspace = true authors = ["Meir Shpilraien "] -edition = "2021" description = "A macros crate for redismodule-rs" -license = "BSD-3-Clause" repository = "https://github.com/RedisLabsModules/redismodule-rs" keywords = ["redis", "plugin"] categories = ["database", "api-bindings"] @@ -20,6 +20,4 @@ serde_syn = "0.1.0" common = { path = "../common" } [lib] -name = "redis_module_macros" -path = "src/lib.rs" proc-macro = true diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c05de718..8cf9c187 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-07-30" +channel = "1.90" components = ["rustfmt", "clippy"] diff --git a/src/context/commands.rs b/src/context/commands.rs index 45898d6c..eed0b1c4 100644 --- a/src/context/commands.rs +++ b/src/context/commands.rs @@ -672,6 +672,7 @@ api! {[ #[cfg(all( any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2", feature = "min-redis-compatibility-version-7-0" @@ -697,6 +698,7 @@ pub fn register_commands(ctx: &Context) -> Status { feature = "min-redis-compatibility-version-6-0" ), not(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2", feature = "min-redis-compatibility-version-7-0" diff --git a/src/context/mod.rs b/src/context/mod.rs index 267558de..b5cfb249 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -56,6 +56,7 @@ pub struct CallOptions { #[derive(Clone)] #[cfg(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2" ))] diff --git a/src/lib.rs b/src/lib.rs index 8d2321bf..eb89aff1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,7 @@ pub use common::AclCategory; pub use crate::context::AclPermissions; #[cfg(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2" ))] diff --git a/test.sh b/test.sh index 89e605c5..da49137f 100755 --- a/test.sh +++ b/test.sh @@ -1,2 +1,2 @@ #!/usr/bin/env sh -cargo test --all --all-targets --no-default-features --features min-redis-compatibility-version-7-4 +cargo test --all --all-targets --no-default-features --features min-redis-compatibility-version-8-0 diff --git a/tests/integration.rs b/tests/integration.rs index 0621fbd4..6589018c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -3,7 +3,7 @@ use std::thread; use std::time::Duration; use std::time::SystemTime; -use crate::utils::{get_redis_connection, start_redis_server_with_module, TestConnection}; +use crate::utils::TestConnection; use anyhow::Context; use anyhow::Result; use redis::{RedisError, RedisResult, Value}; @@ -168,7 +168,7 @@ fn test_string() -> Result<()> { redis::cmd("string.set") .arg(&["key", "value"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let res: String = redis::cmd("string.get").arg(&["key"]).query(&mut con)?; @@ -184,12 +184,12 @@ fn test_scan() -> Result<()> { redis::cmd("set") .arg(&["x", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; redis::cmd("set") .arg(&["y", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let mut res: Vec = redis::cmd("scan_keys").query(&mut con)?; @@ -274,6 +274,7 @@ fn test_stream_reader() -> Result<()> { #[test] #[cfg(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2" ))] @@ -312,7 +313,10 @@ fn test_get_current_user() -> Result<()> { } #[test] -#[cfg(feature = "min-redis-compatibility-version-7-4")] +#[cfg(any( + feature = "min-redis-compatibility-version-8-0", + feature = "min-redis-compatibility-version-7-4" +))] fn test_set_acl_categories() -> Result<()> { let mut con = TestConnection::new("acl"); @@ -380,7 +384,7 @@ fn test_key_space_notifications() -> Result<()> { let res: usize = redis::cmd("events.num_key_miss").query(&mut con)?; assert_eq!(res, 0); - redis::cmd("GET").arg(&["x"]).query(&mut con)?; + redis::cmd("GET").arg(&["x"]).query::<()>(&mut con)?; let res: usize = redis::cmd("events.num_key_miss").query(&mut con)?; assert_eq!(res, 1); @@ -416,7 +420,7 @@ fn test_server_event() -> Result<()> { let mut con = TestConnection::new("server_events"); redis::cmd("flushall") - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run flushall")?; let res: i64 = redis::cmd("num_flushed").query(&mut con)?; @@ -424,7 +428,7 @@ fn test_server_event() -> Result<()> { assert_eq!(res, 1); redis::cmd("flushall") - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let res: i64 = redis::cmd("num_flushed").query(&mut con)?; @@ -433,7 +437,7 @@ fn test_server_event() -> Result<()> { redis::cmd("config") .arg(&["set", "maxmemory", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let res: i64 = redis::cmd("num_max_memory_changes").query(&mut con)?; @@ -442,7 +446,7 @@ fn test_server_event() -> Result<()> { redis::cmd("config") .arg(&["set", "maxmemory", "0"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let res: i64 = redis::cmd("num_max_memory_changes").query(&mut con)?; @@ -533,7 +537,7 @@ fn test_response() -> Result<()> { redis::cmd("hset") .arg(&["k", "a", "b", "c", "d", "e", "b", "f", "g"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; let mut res: Vec = redis::cmd("map.mget") @@ -612,6 +616,7 @@ fn test_redis_value_derive() -> Result<()> { #[test] #[cfg(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2" ))] @@ -635,6 +640,7 @@ fn test_call_blocking() -> Result<()> { #[test] #[cfg(any( + feature = "min-redis-compatibility-version-8-0", feature = "min-redis-compatibility-version-7-4", feature = "min-redis-compatibility-version-7-2" ))] @@ -657,19 +663,19 @@ fn test_open_key_with_flags() -> Result<()> { // Avoid active expriation redis::cmd("DEBUG") .arg(&["SET-ACTIVE-EXPIRE", "0"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run DEBUG SET-ACTIVE-EXPIRE")?; for cmd in ["open_key_with_flags.write", "open_key_with_flags.read"].into_iter() { redis::cmd("set") .arg(&["x", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run string.set")?; // Set experition time to 1 second. redis::cmd("pexpire") .arg(&["x", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run expire")?; // Sleep for 2 seconds, ensure expiration time has passed. @@ -695,8 +701,10 @@ fn test_open_key_with_flags() -> Result<()> { assert_eq!(expired_keys, 0); // Delete key and reset stats - redis::cmd("del").arg(&["x"]).query(&mut con)?; - redis::cmd("config").arg(&["RESETSTAT"]).query(&mut con)?; + redis::cmd("del").arg(&["x"]).query::<()>(&mut con)?; + redis::cmd("config") + .arg(&["RESETSTAT"]) + .query::<()>(&mut con)?; } Ok(()) @@ -709,7 +717,7 @@ fn test_expire() -> Result<()> { // Create a key without TTL redis::cmd("set") .arg(&["key", "value"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run set")?; let ttl: i64 = redis::cmd("ttl").arg(&["key"]).query(&mut con)?; @@ -718,7 +726,7 @@ fn test_expire() -> Result<()> { // Set TTL on the key redis::cmd("expire.cmd") .arg(&["key", "100"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run expire.cmd")?; let ttl: i64 = redis::cmd("ttl").arg(&["key"]).query(&mut con)?; @@ -727,7 +735,7 @@ fn test_expire() -> Result<()> { // Remove TTL on the key redis::cmd("expire.cmd") .arg(&["key", "-1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run expire.cmd")?; let ttl: i64 = redis::cmd("ttl").arg(&["key"]).query(&mut con)?; @@ -743,22 +751,22 @@ fn test_defrag() -> Result<()> { // Configure active defrag redis::cmd("config") .arg(&["set", "hz", "100"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run 'config set hz 100'")?; redis::cmd("config") .arg(&["set", "active-defrag-ignore-bytes", "1"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run 'config set active-defrag-ignore-bytes 1'")?; redis::cmd("config") .arg(&["set", "active-defrag-threshold-lower", "0"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run 'config set active-defrag-threshold-lower 0'")?; redis::cmd("config") .arg(&["set", "active-defrag-cycle-min", "99"]) - .query(&mut con) + .query::<()>(&mut con) .with_context(|| "failed to run 'config set active-defrag-cycle-min 99'")?; // enable active defrag