Skip to content

Commit

Permalink
impl memory help, high level command (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemIsmagilov authored Dec 25, 2024
1 parent b119d68 commit 02bc8dc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,39 @@ pub trait ServerCommands<'a> {
prepare_command(self, cmd("MEMORY").arg("DOCTOR"))
}

/// The command returns a helpful text describing the different MEMORY subcommands.
///
/// # Return
/// An array of strings.
///
/// # Example
/// ```
/// # use rustis::{
/// # client::Client,
/// # commands::ServerCommands,
/// # Result,
/// # };
/// #
/// # #[cfg_attr(feature = "tokio-runtime", tokio::main)]
/// # #[cfg_attr(feature = "async-std-runtime", async_std::main)]
/// # async fn main() -> Result<()> {
/// # let client = Client::connect("127.0.0.1:6379").await?;
/// let result: Vec<String> = client.memory_help().await?;
/// assert!(result.iter().any(|e| e == "HELP"));
/// # Ok(())
/// # }
/// ```
///
/// # See Also
/// [<https://redis.io/commands/memory-help/>](https://redis.io/commands/memory-help/)
#[must_use]
fn memory_help(self) -> PreparedCommand<'a, Self, Vec<String>>
where
Self: Sized,
{
prepare_command(self, cmd("MEMORY").arg("HELP"))
}

/// This command provides an internal statistics report from the memory allocator.
///
/// # Return
Expand Down
12 changes: 12 additions & 0 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,18 @@ async fn memory_doctor() -> Result<()> {
Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn memory_help() -> Result<()> {
let client = get_test_client().await?;

let result = client.memory_help().await?;
assert!(result.iter().any(|e| e == "HELP"));

Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
Expand Down

0 comments on commit 02bc8dc

Please sign in to comment.