1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::{
  commands,
  interfaces::{ClientLike, RedisResult},
  types::FromRedis,
};
use fred_macros::rm_send_if;
use futures::Future;

/// Functions that implement the [slowlog](https://redis.io/commands#server) interface.
#[rm_send_if(feature = "glommio")]
pub trait SlowlogInterface: ClientLike + Sized {
  /// This command is used to read the slow queries log.
  ///
  /// <https://redis.io/commands/slowlog#reading-the-slow-log>
  fn slowlog_get<R>(&self, count: Option<i64>) -> impl Future<Output = RedisResult<R>> + Send
  where
    R: FromRedis,
  {
    async move { commands::slowlog::slowlog_get(self, count).await?.convert() }
  }

  /// This command is used to read length of the slow queries log.
  ///
  /// <https://redis.io/commands/slowlog#obtaining-the-current-length-of-the-slow-log>
  fn slowlog_length<R>(&self) -> impl Future<Output = RedisResult<R>> + Send
  where
    R: FromRedis,
  {
    async move { commands::slowlog::slowlog_length(self).await?.convert() }
  }

  /// This command is used to reset the slow queries log.
  ///
  /// <https://redis.io/commands/slowlog#resetting-the-slow-log>
  fn slowlog_reset(&self) -> impl Future<Output = RedisResult<()>> + Send {
    async move { commands::slowlog::slowlog_reset(self).await }
  }
}