cd src && $(MAKE) $@
cd deps/hiredis && $(MAKE) $@
cd deps/linenoise && $(MAKE) $@
+ cd deps/jemalloc && $(MAKE) distclean
+ cd deps/lua && $(MAKE) $@
+ -(cd deps/jemalloc && $(MAKE) distclean)
$(TARGETS):
cd src && $(MAKE) $@
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
+################################ LUA SCRIPTING ###############################
+
+# Max execution time of a Lua script in milliseconds.
+# This prevents that a programming error generating an infinite loop will block
+# your server forever. Set it to 0 or a negative value for unlimited execution.
+lua-time-limit 60000
+
+ ################################## SLOW LOG ###################################
+
+ # The Redis Slow Log is a system to log queries that exceeded a specified
+ # execution time. The execution time does not include the I/O operations
+ # like talking with the client, sending the reply and so forth,
+ # but just the time needed to actually execute the command (this is the only
+ # stage of command execution where the thread is blocked and can not serve
+ # other requests in the meantime).
+ #
+ # You can configure the slow log with two parameters: one tells Redis
+ # what is the execution time, in microseconds, to exceed in order for the
+ # command to get logged, and the other parameter is the length of the
+ # slow log. When a new command is logged the oldest one is removed from the
+ # queue of logged commands.
+
+ # The following time is expressed in microseconds, so 1000000 is equivalent
+ # to one second. Note that a negative number disables the slow log, while
+ # a value of zero forces the logging of every command.
+ slowlog-log-slower-than 10000
+
+ # There is no limit to this length. Just be aware that it will consume memory.
+ # You can reclaim memory used by the slow log with SLOWLOG RESET.
+ slowlog-max-len 1024
+
############################### ADVANCED CONFIG ###############################
# Hashes are encoded in a special way (much more memory efficient) when they
QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
endif
- OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o scripting.o
-OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o slowlog.o
++OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endian.o slowlog.o scripting.o
BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o
CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o
} else if (!strcasecmp(argv[0],"cluster-config-file") && argc == 2) {
zfree(server.cluster.configfile);
server.cluster.configfile = zstrdup(argv[1]);
+ } else if (!strcasecmp(argv[0],"lua-time-limit") && argc == 2) {
+ server.lua_time_limit = strtoll(argv[1],NULL,10);
+ } else if (!strcasecmp(argv[0],"slowlog-log-slower-than") &&
+ argc == 2)
+ {
+ server.slowlog_log_slower_than = strtoll(argv[1],NULL,10);
+ } else if (!strcasecmp(argv[0],"slowlog-max-len") && argc == 2) {
+ server.slowlog_max_len = strtoll(argv[1],NULL,10);
} else {
err = "Bad directive or wrong number of arguments"; goto loaderr;
}
} else if (!strcasecmp(c->argv[2]->ptr,"zset-max-ziplist-value")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.zset_max_ziplist_value = ll;
+ } else if (!strcasecmp(c->argv[2]->ptr,"lua-time-limit")) {
+ if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
+ server.lua_time_limit = ll;
+ } else if (!strcasecmp(c->argv[2]->ptr,"slowlog-log-slower-than")) {
+ if (getLongLongFromObject(o,&ll) == REDIS_ERR) goto badfmt;
+ server.slowlog_log_slower_than = ll;
+ } else if (!strcasecmp(c->argv[2]->ptr,"slowlog-max-len")) {
+ if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
+ server.slowlog_max_len = (unsigned)ll;
} else {
addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s",
(char*)c->argv[2]->ptr);
addReplyBulkLongLong(c,server.zset_max_ziplist_value);
matches++;
}
+ if (stringmatch(pattern,"lua-time-limit",0)) {
+ addReplyBulkCString(c,"lua-time-limit");
+ addReplyBulkLongLong(c,server.lua_time_limit);
+ if (stringmatch(pattern,"slowlog-log-slower-than",0)) {
+ addReplyBulkCString(c,"slowlog-log-slower-than");
+ addReplyBulkLongLong(c,server.slowlog_log_slower_than);
+ matches++;
+ }
+ if (stringmatch(pattern,"slowlog-max-len",0)) {
+ addReplyBulkCString(c,"slowlog-max-len");
+ addReplyBulkLongLong(c,server.slowlog_max_len);
matches++;
}
setDeferredMultiBulkLength(c,replylen,matches*2);
{"dump",dumpCommand,2,0,NULL,0,0,0,0,0},
{"object",objectCommand,-2,0,NULL,0,0,0,0,0},
{"client",clientCommand,-2,0,NULL,0,0,0,0,0},
- {"evalsha",evalShaCommand,-3,REDIS_CMD_DENYOOM,zunionInterGetKeys,0,0,0,0,0}
+ {"eval",evalCommand,-3,REDIS_CMD_DENYOOM,zunionInterGetKeys,0,0,0,0,0},
++ {"evalsha",evalShaCommand,-3,REDIS_CMD_DENYOOM,zunionInterGetKeys,0,0,0,0,0},
+ {"slowlog",slowlogCommand,-2,0,NULL,0,0,0,0,0}
};
/*============================ Utility functions ============================ */
}
if (server.cluster_enabled) clusterInit();
+ scriptingInit();
+ slowlogInit();
srand(time(NULL)^getpid());
}
#include <pthread.h>
#include <syslog.h>
#include <netinet/in.h>
+#include <lua.h>
- #include "ae.h" /* Event driven programming library */
- #include "sds.h" /* Dynamic safe strings */
- #include "dict.h" /* Hash tables */
- #include "adlist.h" /* Linked lists */
+ #include "ae.h" /* Event driven programming library */
+ #include "sds.h" /* Dynamic safe strings */
+ #include "dict.h" /* Hash tables */
+ #include "adlist.h" /* Linked lists */
#include "zmalloc.h" /* total memory usage aware version of malloc/free */
- #include "anet.h" /* Networking the easy way */
- #include "zipmap.h" /* Compact string -> string data structure */
+ #include "anet.h" /* Networking the easy way */
+ #include "zipmap.h" /* Compact string -> string data structure */
#include "ziplist.h" /* Compact list data structure */
- #include "intset.h" /* Compact integer set structure */
- #include "version.h"
- #include "util.h"
+ #include "intset.h" /* Compact integer set structure */
+ #include "version.h" /* Version macro */
+ #include "util.h" /* Misc functions useful in many places */
/* Error codes */
#define REDIS_OK 0
void setupSignalHandlers(void);
struct redisCommand *lookupCommand(sds name);
struct redisCommand *lookupCommandByCString(char *s);
- void call(redisClient *c, struct redisCommand *cmd);
+ void call(redisClient *c);
int prepareForShutdown();
void redisLog(int level, const char *fmt, ...);
+void redisLogRaw(int level, const char *msg);
void usage();
void updateDictResizePolicy(void);
int htNeedsResize(dict *dict);
source tests/support/test.tcl
source tests/support/util.tcl
+ set ::all_tests {
+ unit/printver
+ unit/auth
+ unit/protocol
+ unit/basic
+ unit/type/list
+ unit/type/list-2
+ unit/type/list-3
+ unit/type/set
+ unit/type/zset
+ unit/type/hash
+ unit/sort
+ unit/expire
+ unit/other
+ unit/cas
+ unit/quit
+ integration/replication
+ integration/replication-2
+ integration/replication-3
+ integration/aof
+ unit/pubsub
+ unit/slowlog
++ unit/scripting
+ }
+ # Index to the next test to run in the ::all_tests list.
+ set ::next_test 0
+
set ::host 127.0.0.1
set ::port 16379
set ::traceleaks 0