和mongo的slowlog一样,redis中对于操作时间较长(默认为10秒)的命令也会记录下来,不过它将它们保存在redisServer结构中的slowlog这个链表中,新进来的log排在链表头部,这个链表的长度可以配置,超过长度(默认为128)则将链表尾部元素踢掉。

链表中的元素是slowlogEntry:

// This structure defines an entry inside the slow log list.
typedef struct slowlogEntry {
  robj** argv;
  int argc;
  long long id;  // Unique entry identifier.
  long long duration;  // Time spent by the query, in nanoseconds.
  time_t time;  // Unix time at which the query was executed.
} slowlogEntry;

argv最多只保存32个,如果多出来了,则第32个改为"... (%d more arguments)",如果参数是字符串并且长度超过128,则将其替换为"... (%lu more bytes)",argv共享的是client中的argv,所以push  entry时会增加原有argv的引用计数。

j接口如下:

// Exported API.
void slowlogInit(void);
void slowlogPushEntryIfNeeded(robj** argv, int argc, long long duration);

// Exported commands.
void slowlogCommand(redisClient* c);

slowlogCommand是执行slowlog命令,命令带的参数在redisClient中的argv中。看起来,它支持reset,len,get三个子命令。reset,len不用说,get n代表获取最新的n条slowlog记录。

Redis slowlog的更多相关文章

  1. 轻松使用 Redis slowlog

    之前中秋项目搞活动,用户比较活跃 SE.Redis 频繁报 Timeout 异常,狂翻了一波 issues 发现提这个问题还蛮多的,作者非常频繁的提到使用 slowlog 这个命令进行排查,那么问题就 ...

  2. Redis slowlog慢查询

    slowlog (阅读原文) 此命令用于读取和重置redis慢请求日志 redis slow log概述 redis的slow log记录了那些执行时间超过规定时长的请求.执行时间不包括I/O操作(比 ...

  3. redis slowlog 慢查询日志

    设置 config set slowlog-log-slower-than 10000(微秒) //查看redis时间超过上面设置的阀值的key slowlog len 有几个key slowlog ...

  4. Redis慢链接查看

    设置定义慢日志(小于n微秒的定义为慢日志):CONFIG SET slowlog-log-slower-than n 注:1秒 = 1,000,000微秒设置服务器保存的慢日志最多条数:config ...

  5. PHP Redis 全部操作方法

    Classes and methods Usage Class Redis Class RedisException Predefined constants Class Redis Descript ...

  6. redis状态查看

      https://redis.readthedocs.org/en/latest/server/slowlog.html   https://redis.readthedocs.org/en/lat ...

  7. redis专题--slow log详解

    SLOWLOG subcommand [argument] 什么是 SLOWLOG Slow log 是 Redis 用来记录查询执行时间的日志系统. 查询执行时间指的是不包括像客户端响应(talki ...

  8. Redis测井系统

    什么是 SLOWLOG Slow log 是 Redis 用来记录查询运行时间的日志系统. 查询运行时间指的是不包含像client响应(talking).发送回复等 IO 操作,而单单是运行一个查询命 ...

  9. 1、redis 基础

    1.1 导言 如果你从来没使用过 Redis 数据库,那你肯定会问,为什么我们要学 Redis数据库,我只使用 MySQL 或 Oracle 就够了.其实 Redis 虽叫数据库,可又不是传统意义上的 ...

随机推荐

  1. URAL 1792. Hamming Code (枚举)

    1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersectin ...

  2. Goodle Clean设计架构

    Goodle Clean设计架构 23 * @param <P> the response type 24 */ 25 public abstract class UseCase<Q ...

  3. Debian安装Nexus

    前置条件 安装jdk (如果使用 nexus-2.6 以上版本需要jdk7) 1 apt-get install openjdk-6-jre / apt-get install openjdk-6-j ...

  4. 使用 Spring RestTemplate 调用 rest 服务时自定义请求头(custom HTTP headers)

    在 Spring 3.0 中可以通过  HttpEntity 对象自定义请求头信息,如: private static final String APPLICATION_PDF = "app ...

  5. Swift - 正则表达式的使用(附用户名、邮箱、URL等常用格式验证)

    Swift虽然是一个新出的语言,但却不提供专门的处理正则的语法和类.所以我们只能使用古老的NSRegularExpression类进行正则匹配. 即先接受一个正则表达式的字符串,由此生成NSRegul ...

  6. SVN 1.8.x 服务器安装(转)

    目录[-] 一. SVN 服务器下载.安装 1. 关于 Subversion 1.8.11 2. 兼容性问题 3. 安装包下载 3.1 VisualSVN 3.2 Win32Svn 3.3 SlikS ...

  7. C#中System.Globalization.DateTimeFormatInfo.InvariantInfo怎么用

    原文  C#中System.Globalization.DateTimeFormatInfo.InvariantInfo怎么用 在开发的时候,碰到下面这样一个问题: 在程序中显示当前系统时间,但是有一 ...

  8. Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)

    Acknowledgments I would like to thank Jacob Kjome for reviewing early drafts of this document. His c ...

  9. 在Python中使用正则表达式同时匹配邮箱和电话并进行简单的分类

    在Python使用正则表达式需要使用re(regular exprssion)模块,使用正则表达式的难点就在于如何写好p=re.compile(r' 正则表达式')的内容. 下面是在Python中使用 ...

  10. Tomcat详细用法学习(四)

    本篇接上一篇<Tomcat详细用法学习(三)>,主要讲解配置虚拟主机.打包web应用成war包和Tomcat的体系结构 对于Tomcat服务器,可以放置多个网站(多个web应用),这就是讲 ...