8 #include "solarisfixes.h"
21 #include <netinet/in.h>
25 #include "ae.h" /* Event driven programming library */
26 #include "sds.h" /* Dynamic safe strings */
27 #include "dict.h" /* Hash tables */
28 #include "adlist.h" /* Linked lists */
29 #include "zmalloc.h" /* total memory usage aware version of malloc/free */
30 #include "anet.h" /* Networking the easy way */
31 #include "zipmap.h" /* Compact string -> string data structure */
32 #include "ziplist.h" /* Compact list data structure */
33 #include "intset.h" /* Compact integer set structure */
34 #include "version.h" /* Version macro */
35 #include "util.h" /* Misc functions useful in many places */
41 /* Static server configuration */
42 #define REDIS_SERVERPORT 6379 /* TCP port */
43 #define REDIS_MAXIDLETIME 0 /* default client timeout: infinite */
44 #define REDIS_DEFAULT_DBNUM 16
45 #define REDIS_CONFIGLINE_MAX 1024
46 #define REDIS_EXPIRELOOKUPS_PER_CRON 10 /* lookup 10 expires per loop */
47 #define REDIS_MAX_WRITE_PER_EVENT (1024*64)
48 #define REDIS_SHARED_INTEGERS 10000
49 #define REDIS_MAX_LOGMSG_LEN 1024 /* Default maximum length of syslog messages */
50 #define REDIS_AOF_REWRITE_PERC 100
51 #define REDIS_AOF_REWRITE_MIN_SIZE (1024*1024)
52 #define REDIS_AOF_REWRITE_ITEMS_PER_CMD 64
53 #define REDIS_SLOWLOG_LOG_SLOWER_THAN 10000
54 #define REDIS_SLOWLOG_MAX_LEN 64
55 #define REDIS_MAX_CLIENTS 10000
57 #define REDIS_REPL_TIMEOUT 60
58 #define REDIS_REPL_PING_SLAVE_PERIOD 10
60 /* Protocol and I/O related defines */
61 #define REDIS_MAX_QUERYBUF_LEN (1024*1024*1024) /* 1GB max query buffer. */
62 #define REDIS_IOBUF_LEN (1024*16) /* Generic I/O buffer size */
63 #define REDIS_REPLY_CHUNK_BYTES (16*1024) /* 16k output buffer */
64 #define REDIS_INLINE_MAX_SIZE (1024*64) /* Max size of inline reads */
65 #define REDIS_MBULK_BIG_ARG (1024*32)
67 /* Hash table parameters */
68 #define REDIS_HT_MINFILL 10 /* Minimal hash table fill 10% */
70 /* Command flags. Please check the command table defined in the redis.c file
71 * for more information about the meaning of every flag. */
72 #define REDIS_CMD_WRITE 1 /* "w" flag */
73 #define REDIS_CMD_READONLY 2 /* "r" flag */
74 #define REDIS_CMD_DENYOOM 4 /* "m" flag */
75 #define REDIS_CMD_FORCE_REPLICATION 8 /* "f" flag */
76 #define REDIS_CMD_ADMIN 16 /* "a" flag */
77 #define REDIS_CMD_PUBSUB 32 /* "p" flag */
78 #define REDIS_CMD_NOSCRIPT 64 /* "s" flag */
79 #define REDIS_CMD_RANDOM 128 /* "R" flag */
80 #define REDIS_CMD_SORT_FOR_SCRIPT 256 /* "S" flag */
83 #define REDIS_STRING 0
88 #define REDIS_VMPOINTER 8
90 /* Objects encoding. Some kind of objects like Strings and Hashes can be
91 * internally represented in multiple ways. The 'encoding' field of the object
92 * is set to one of this fields for this object. */
93 #define REDIS_ENCODING_RAW 0 /* Raw representation */
94 #define REDIS_ENCODING_INT 1 /* Encoded as integer */
95 #define REDIS_ENCODING_HT 2 /* Encoded as hash table */
96 #define REDIS_ENCODING_ZIPMAP 3 /* Encoded as zipmap */
97 #define REDIS_ENCODING_LINKEDLIST 4 /* Encoded as regular linked list */
98 #define REDIS_ENCODING_ZIPLIST 5 /* Encoded as ziplist */
99 #define REDIS_ENCODING_INTSET 6 /* Encoded as intset */
100 #define REDIS_ENCODING_SKIPLIST 7 /* Encoded as skiplist */
102 /* Defines related to the dump file format. To store 32 bits lengths for short
103 * keys requires a lot of space, so we check the most significant 2 bits of
104 * the first byte to interpreter the length:
106 * 00|000000 => if the two MSB are 00 the len is the 6 bits of this byte
107 * 01|000000 00000000 => 01, the len is 14 byes, 6 bits + 8 bits of next byte
108 * 10|000000 [32 bit integer] => if it's 01, a full 32 bit len will follow
109 * 11|000000 this means: specially encoded object will follow. The six bits
110 * number specify the kind of object that follows.
111 * See the REDIS_RDB_ENC_* defines.
113 * Lenghts up to 63 are stored using a single byte, most DB keys, and may
114 * values, will fit inside. */
115 #define REDIS_RDB_6BITLEN 0
116 #define REDIS_RDB_14BITLEN 1
117 #define REDIS_RDB_32BITLEN 2
118 #define REDIS_RDB_ENCVAL 3
119 #define REDIS_RDB_LENERR UINT_MAX
121 /* When a length of a string object stored on disk has the first two bits
122 * set, the remaining two bits specify a special encoding for the object
123 * accordingly to the following defines: */
124 #define REDIS_RDB_ENC_INT8 0 /* 8 bit signed integer */
125 #define REDIS_RDB_ENC_INT16 1 /* 16 bit signed integer */
126 #define REDIS_RDB_ENC_INT32 2 /* 32 bit signed integer */
127 #define REDIS_RDB_ENC_LZF 3 /* string compressed with FASTLZ */
130 #define REDIS_AOF_OFF 0 /* AOF is off */
131 #define REDIS_AOF_ON 1 /* AOF is on */
132 #define REDIS_AOF_WAIT_REWRITE 2 /* AOF waits rewrite to start appending */
135 #define REDIS_SLAVE 1 /* This client is a slave server */
136 #define REDIS_MASTER 2 /* This client is a master server */
137 #define REDIS_MONITOR 4 /* This client is a slave monitor, see MONITOR */
138 #define REDIS_MULTI 8 /* This client is in a MULTI context */
139 #define REDIS_BLOCKED 16 /* The client is waiting in a blocking operation */
140 #define REDIS_DIRTY_CAS 64 /* Watched keys modified. EXEC will fail. */
141 #define REDIS_CLOSE_AFTER_REPLY 128 /* Close after writing entire reply. */
142 #define REDIS_UNBLOCKED 256 /* This client was unblocked and is stored in
143 server.unblocked_clients */
144 #define REDIS_LUA_CLIENT 512 /* This is a non connected client used by Lua */
145 #define REDIS_ASKING 1024 /* Client issued the ASKING command */
146 #define REDIS_CLOSE_ASAP 2048 /* Close this client ASAP */
148 /* Client request types */
149 #define REDIS_REQ_INLINE 1
150 #define REDIS_REQ_MULTIBULK 2
152 /* Client classes for client limits, currently used only for
153 * the max-client-output-buffer limit implementation. */
154 #define REDIS_CLIENT_LIMIT_CLASS_NORMAL 0
155 #define REDIS_CLIENT_LIMIT_CLASS_SLAVE 1
156 #define REDIS_CLIENT_LIMIT_CLASS_PUBSUB 2
157 #define REDIS_CLIENT_LIMIT_NUM_CLASSES 3
159 /* Slave replication state - slave side */
160 #define REDIS_REPL_NONE 0 /* No active replication */
161 #define REDIS_REPL_CONNECT 1 /* Must connect to master */
162 #define REDIS_REPL_CONNECTING 2 /* Connecting to master */
163 #define REDIS_REPL_TRANSFER 3 /* Receiving .rdb from master */
164 #define REDIS_REPL_CONNECTED 4 /* Connected to master */
166 /* Synchronous read timeout - slave side */
167 #define REDIS_REPL_SYNCIO_TIMEOUT 5
169 /* Slave replication state - from the point of view of master
170 * Note that in SEND_BULK and ONLINE state the slave receives new updates
171 * in its output queue. In the WAIT_BGSAVE state instead the server is waiting
172 * to start the next background saving in order to send updates to it. */
173 #define REDIS_REPL_WAIT_BGSAVE_START 3 /* master waits bgsave to start feeding it */
174 #define REDIS_REPL_WAIT_BGSAVE_END 4 /* master waits bgsave to start bulk DB transmission */
175 #define REDIS_REPL_SEND_BULK 5 /* master is sending the bulk DB */
176 #define REDIS_REPL_ONLINE 6 /* bulk DB already transmitted, receive updates */
178 /* List related stuff */
182 /* Sort operations */
183 #define REDIS_SORT_GET 0
184 #define REDIS_SORT_ASC 1
185 #define REDIS_SORT_DESC 2
186 #define REDIS_SORTKEY_MAX 1024
189 #define REDIS_DEBUG 0
190 #define REDIS_VERBOSE 1
191 #define REDIS_NOTICE 2
192 #define REDIS_WARNING 3
193 #define REDIS_LOG_RAW (1<<10) /* Modifier to log without timestamp */
195 /* Anti-warning macro... */
196 #define REDIS_NOTUSED(V) ((void) V)
198 #define ZSKIPLIST_MAXLEVEL 32 /* Should be enough for 2^32 elements */
199 #define ZSKIPLIST_P 0.25 /* Skiplist P = 1/4 */
201 /* Append only defines */
202 #define AOF_FSYNC_NO 0
203 #define AOF_FSYNC_ALWAYS 1
204 #define AOF_FSYNC_EVERYSEC 2
206 /* Zip structure related defaults */
207 #define REDIS_HASH_MAX_ZIPMAP_ENTRIES 512
208 #define REDIS_HASH_MAX_ZIPMAP_VALUE 64
209 #define REDIS_LIST_MAX_ZIPLIST_ENTRIES 512
210 #define REDIS_LIST_MAX_ZIPLIST_VALUE 64
211 #define REDIS_SET_MAX_INTSET_ENTRIES 512
212 #define REDIS_ZSET_MAX_ZIPLIST_ENTRIES 128
213 #define REDIS_ZSET_MAX_ZIPLIST_VALUE 64
215 /* Sets operations codes */
216 #define REDIS_OP_UNION 0
217 #define REDIS_OP_DIFF 1
218 #define REDIS_OP_INTER 2
220 /* Redis maxmemory strategies */
221 #define REDIS_MAXMEMORY_VOLATILE_LRU 0
222 #define REDIS_MAXMEMORY_VOLATILE_TTL 1
223 #define REDIS_MAXMEMORY_VOLATILE_RANDOM 2
224 #define REDIS_MAXMEMORY_ALLKEYS_LRU 3
225 #define REDIS_MAXMEMORY_ALLKEYS_RANDOM 4
226 #define REDIS_MAXMEMORY_NO_EVICTION 5
229 #define REDIS_LUA_TIME_LIMIT 5000 /* milliseconds */
232 #define UNIT_SECONDS 0
233 #define UNIT_MILLISECONDS 1
236 #define REDIS_SHUTDOWN_SAVE 1 /* Force SAVE on SHUTDOWN even if no save
237 points are configured. */
238 #define REDIS_SHUTDOWN_NOSAVE 2 /* Don't SAVE on SHUTDOWN. */
240 /* Command call flags, see call() function */
241 #define REDIS_CALL_NONE 0
242 #define REDIS_CALL_SLOWLOG 1
243 #define REDIS_CALL_STATS 2
244 #define REDIS_CALL_PROPAGATE 4
245 #define REDIS_CALL_FULL (REDIS_CALL_SLOWLOG | REDIS_CALL_STATS | REDIS_CALL_PROPAGATE)
247 /* We can print the stacktrace, so our assert is defined this way: */
248 #define redisAssertWithInfo(_c,_o,_e) ((_e)?(void)0 : (_redisAssertWithInfo(_c,_o,#_e,__FILE__,__LINE__),_exit(1)))
249 #define redisAssert(_e) ((_e)?(void)0 : (_redisAssert(#_e,__FILE__,__LINE__),_exit(1)))
250 #define redisPanic(_e) _redisPanic(#_e,__FILE__,__LINE__),_exit(1)
252 /*-----------------------------------------------------------------------------
254 *----------------------------------------------------------------------------*/
256 /* A redis object, that is a type able to hold a string / list / set */
258 /* The actual Redis Object */
259 #define REDIS_LRU_CLOCK_MAX ((1<<21)-1) /* Max value of obj->lru */
260 #define REDIS_LRU_CLOCK_RESOLUTION 10 /* LRU clock resolution in seconds */
261 typedef struct redisObject
{
263 unsigned notused
:2; /* Not used */
265 unsigned lru
:22; /* lru time (relative to server.lruclock) */
270 /* Macro used to initalize a Redis object allocated on the stack.
271 * Note that this macro is taken near the structure definition to make sure
272 * we'll update it when the structure is changed, to avoid bugs like
273 * bug #85 introduced exactly in this way. */
274 #define initStaticStringObject(_var,_ptr) do { \
276 _var.type = REDIS_STRING; \
277 _var.encoding = REDIS_ENCODING_RAW; \
281 typedef struct redisDb
{
282 dict
*dict
; /* The keyspace for this DB */
283 dict
*expires
; /* Timeout of keys with a timeout set */
284 dict
*blocking_keys
; /* Keys with clients waiting for data (BLPOP) */
285 dict
*watched_keys
; /* WATCHED keys for MULTI/EXEC CAS */
289 /* Client MULTI/EXEC state */
290 typedef struct multiCmd
{
293 struct redisCommand
*cmd
;
296 typedef struct multiState
{
297 multiCmd
*commands
; /* Array of MULTI commands */
298 int count
; /* Total number of MULTI commands */
301 typedef struct blockingState
{
302 robj
**keys
; /* The key we are waiting to terminate a blocking
303 * operation such as BLPOP. Otherwise NULL. */
304 int count
; /* Number of blocking keys */
305 time_t timeout
; /* Blocking operation timeout. If UNIX current time
306 * is >= timeout then the operation timed out. */
307 robj
*target
; /* The key that should receive the element,
311 /* With multiplexing we need to take per-clinet state.
312 * Clients are taken in a liked list. */
313 typedef struct redisClient
{
320 struct redisCommand
*cmd
, *lastcmd
;
322 int multibulklen
; /* number of multi bulk arguments left to read */
323 long bulklen
; /* length of bulk argument in multi bulk request */
325 unsigned long reply_bytes
; /* Tot bytes of objects in reply list */
327 time_t lastinteraction
; /* time of the last interaction, used for timeout */
328 time_t obuf_soft_limit_reached_time
;
329 int flags
; /* REDIS_SLAVE | REDIS_MONITOR | REDIS_MULTI ... */
330 int slaveseldb
; /* slave selected db, if this client is a slave */
331 int authenticated
; /* when requirepass is non-NULL */
332 int replstate
; /* replication state if this is a slave */
333 int repldbfd
; /* replication DB file descriptor */
334 long repldboff
; /* replication DB file offset */
335 off_t repldbsize
; /* replication DB file size */
336 multiState mstate
; /* MULTI/EXEC state */
337 blockingState bpop
; /* blocking state */
338 list
*io_keys
; /* Keys this client is waiting to be loaded from the
339 * swap file in order to continue. */
340 list
*watched_keys
; /* Keys WATCHED for MULTI/EXEC CAS */
341 dict
*pubsub_channels
; /* channels a client is interested in (SUBSCRIBE) */
342 list
*pubsub_patterns
; /* patterns a client is interested in (SUBSCRIBE) */
344 /* Response buffer */
346 char buf
[REDIS_REPLY_CHUNK_BYTES
];
354 struct sharedObjectsStruct
{
355 robj
*crlf
, *ok
, *err
, *emptybulk
, *czero
, *cone
, *cnegone
, *pong
, *space
,
356 *colon
, *nullbulk
, *nullmultibulk
, *queued
,
357 *emptymultibulk
, *wrongtypeerr
, *nokeyerr
, *syntaxerr
, *sameobjecterr
,
358 *outofrangeerr
, *noscripterr
, *loadingerr
, *slowscripterr
, *plus
,
359 *select0
, *select1
, *select2
, *select3
, *select4
,
360 *select5
, *select6
, *select7
, *select8
, *select9
,
361 *messagebulk
, *pmessagebulk
, *subscribebulk
, *unsubscribebulk
, *mbulk3
,
362 *mbulk4
, *psubscribebulk
, *punsubscribebulk
,
363 *integers
[REDIS_SHARED_INTEGERS
];
366 /* ZSETs use a specialized version of Skiplists */
367 typedef struct zskiplistNode
{
370 struct zskiplistNode
*backward
;
371 struct zskiplistLevel
{
372 struct zskiplistNode
*forward
;
377 typedef struct zskiplist
{
378 struct zskiplistNode
*header
, *tail
;
379 unsigned long length
;
383 typedef struct zset
{
388 typedef struct clientBufferLimitsConfig
{
389 unsigned long long hard_limit_bytes
;
390 unsigned long long soft_limit_bytes
;
391 time_t soft_limit_seconds
;
392 } clientBufferLimitsConfig
;
394 /*-----------------------------------------------------------------------------
395 * Redis cluster data structures
396 *----------------------------------------------------------------------------*/
398 #define REDIS_CLUSTER_SLOTS 4096
399 #define REDIS_CLUSTER_OK 0 /* Everything looks ok */
400 #define REDIS_CLUSTER_FAIL 1 /* The cluster can't work */
401 #define REDIS_CLUSTER_NEEDHELP 2 /* The cluster works, but needs some help */
402 #define REDIS_CLUSTER_NAMELEN 40 /* sha1 hex length */
403 #define REDIS_CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */
407 /* clusterLink encapsulates everything needed to talk with a remote node. */
408 typedef struct clusterLink
{
409 int fd
; /* TCP socket file descriptor */
410 sds sndbuf
; /* Packet send buffer */
411 sds rcvbuf
; /* Packet reception buffer */
412 struct clusterNode
*node
; /* Node related to this link if any, or NULL */
416 #define REDIS_NODE_MASTER 1 /* The node is a master */
417 #define REDIS_NODE_SLAVE 2 /* The node is a slave */
418 #define REDIS_NODE_PFAIL 4 /* Failure? Need acknowledge */
419 #define REDIS_NODE_FAIL 8 /* The node is believed to be malfunctioning */
420 #define REDIS_NODE_MYSELF 16 /* This node is myself */
421 #define REDIS_NODE_HANDSHAKE 32 /* We have still to exchange the first ping */
422 #define REDIS_NODE_NOADDR 64 /* We don't know the address of this node */
423 #define REDIS_NODE_MEET 128 /* Send a MEET message to this node */
424 #define REDIS_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
427 char name
[REDIS_CLUSTER_NAMELEN
]; /* Node name, hex string, sha1-size */
428 int flags
; /* REDIS_NODE_... */
429 unsigned char slots
[REDIS_CLUSTER_SLOTS
/8]; /* slots handled by this node */
430 int numslaves
; /* Number of slave nodes, if this is a master */
431 struct clusterNode
**slaves
; /* pointers to slave nodes */
432 struct clusterNode
*slaveof
; /* pointer to the master node */
433 time_t ping_sent
; /* Unix time we sent latest ping */
434 time_t pong_received
; /* Unix time we received the pong */
435 char *configdigest
; /* Configuration digest of this node */
436 time_t configdigest_ts
; /* Configuration digest timestamp */
437 char ip
[16]; /* Latest known IP address of this node */
438 int port
; /* Latest known port of this node */
439 clusterLink
*link
; /* TCP/IP link with this node */
441 typedef struct clusterNode clusterNode
;
445 clusterNode
*myself
; /* This node */
446 int state
; /* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */
448 dict
*nodes
; /* Hash table of name -> clusterNode structures */
449 clusterNode
*migrating_slots_to
[REDIS_CLUSTER_SLOTS
];
450 clusterNode
*importing_slots_from
[REDIS_CLUSTER_SLOTS
];
451 clusterNode
*slots
[REDIS_CLUSTER_SLOTS
];
452 zskiplist
*slots_to_keys
;
455 /* Redis cluster messages header */
457 /* Note that the PING, PONG and MEET messages are actually the same exact
458 * kind of packet. PONG is the reply to ping, in the extact format as a PING,
459 * while MEET is a special PING that forces the receiver to add the sender
460 * as a node (if it is not already in the list). */
461 #define CLUSTERMSG_TYPE_PING 0 /* Ping */
462 #define CLUSTERMSG_TYPE_PONG 1 /* Pong (reply to Ping) */
463 #define CLUSTERMSG_TYPE_MEET 2 /* Meet "let's join" message */
464 #define CLUSTERMSG_TYPE_FAIL 3 /* Mark node xxx as failing */
465 #define CLUSTERMSG_TYPE_PUBLISH 4 /* Pub/Sub Publish propatagion */
467 /* Initially we don't know our "name", but we'll find it once we connect
468 * to the first node, using the getsockname() function. Then we'll use this
469 * address for all the next messages. */
471 char nodename
[REDIS_CLUSTER_NAMELEN
];
473 uint32_t pong_received
;
474 char ip
[16]; /* IP address last time it was seen */
475 uint16_t port
; /* port last time it was seen */
477 uint32_t notused
; /* for 64 bit alignment */
478 } clusterMsgDataGossip
;
481 char nodename
[REDIS_CLUSTER_NAMELEN
];
482 } clusterMsgDataFail
;
485 uint32_t channel_len
;
486 uint32_t message_len
;
487 unsigned char bulk_data
[8]; /* defined as 8 just for alignment concerns. */
488 } clusterMsgDataPublish
;
490 union clusterMsgData
{
491 /* PING, MEET and PONG */
493 /* Array of N clusterMsgDataGossip structures */
494 clusterMsgDataGossip gossip
[1];
499 clusterMsgDataFail about
;
504 clusterMsgDataPublish msg
;
509 uint32_t totlen
; /* Total length of this message */
510 uint16_t type
; /* Message type */
511 uint16_t count
; /* Only used for some kind of messages. */
512 char sender
[REDIS_CLUSTER_NAMELEN
]; /* Name of the sender node */
513 unsigned char myslots
[REDIS_CLUSTER_SLOTS
/8];
514 char slaveof
[REDIS_CLUSTER_NAMELEN
];
515 char configdigest
[32];
516 uint16_t port
; /* Sender TCP base port */
517 unsigned char state
; /* Cluster state from the POV of the sender */
518 unsigned char notused
[5]; /* Reserved for future use. For alignment. */
519 union clusterMsgData data
;
522 /*-----------------------------------------------------------------------------
523 * Global server state
524 *----------------------------------------------------------------------------*/
529 dict
*commands
; /* Command table hahs table */
531 unsigned lruclock
:22; /* Clock incrementing every minute, for LRU */
532 unsigned lruclock_padding
:10;
533 int shutdown_asap
; /* SHUTDOWN needed ASAP */
534 int activerehashing
; /* Incremental rehash in serverCron() */
535 char *requirepass
; /* Pass for AUTH command, or NULL */
536 char *pidfile
; /* PID file path */
537 int arch_bits
; /* 32 or 64 depending on sizeof(long) */
539 int port
; /* TCP listening port */
540 char *bindaddr
; /* Bind address or NULL */
541 char *unixsocket
; /* UNIX socket path */
542 mode_t unixsocketperm
; /* UNIX socket permission */
543 int ipfd
; /* TCP socket file descriptor */
544 int sofd
; /* Unix socket file descriptor */
545 int cfd
; /* Cluster bus lisetning socket */
546 list
*clients
; /* List of active clients */
547 list
*clients_to_close
; /* Clients to close asynchronously */
548 list
*slaves
, *monitors
; /* List of slaves and MONITORs */
549 redisClient
*current_client
; /* Current client, only used on crash report */
550 char neterr
[ANET_ERR_LEN
]; /* Error buffer for anet.c */
551 /* RDB / AOF loading information */
552 int loading
; /* We are loading data from disk if true */
553 off_t loading_total_bytes
;
554 off_t loading_loaded_bytes
;
555 time_t loading_start_time
;
556 /* Fast pointers to often looked up command */
557 struct redisCommand
*delCommand
, *multiCommand
;
558 int cronloops
; /* Number of times the cron function run */
559 time_t lastsave
; /* Unix time of last save succeeede */
560 /* Fields used only for stats */
561 time_t stat_starttime
; /* Server start time */
562 long long stat_numcommands
; /* Number of processed commands */
563 long long stat_numconnections
; /* Number of connections received */
564 long long stat_expiredkeys
; /* Number of expired keys */
565 long long stat_evictedkeys
; /* Number of evicted keys (maxmemory) */
566 long long stat_keyspace_hits
; /* Number of successful lookups of keys */
567 long long stat_keyspace_misses
; /* Number of failed lookups of keys */
568 size_t stat_peak_memory
; /* Max used memory record */
569 long long stat_fork_time
; /* Time needed to perform latets fork() */
570 long long stat_rejected_conn
; /* Clients rejected because of maxclients */
571 list
*slowlog
; /* SLOWLOG list of commands */
572 long long slowlog_entry_id
; /* SLOWLOG current entry ID */
573 long long slowlog_log_slower_than
; /* SLOWLOG time limit (to get logged) */
574 unsigned long slowlog_max_len
; /* SLOWLOG max number of items logged */
576 int verbosity
; /* Loglevel in redis.conf */
577 int maxidletime
; /* Client timeout in seconds */
578 size_t client_max_querybuf_len
; /* Limit for client query buffer length */
579 int dbnum
; /* Total number of configured DBs */
580 int daemonize
; /* True if running as a daemon */
581 clientBufferLimitsConfig client_obuf_limits
[REDIS_CLIENT_LIMIT_NUM_CLASSES
];
582 /* AOF persistence */
583 int aof_state
; /* REDIS_AOF_(ON|OFF|WAIT_REWRITE) */
584 int aof_fsync
; /* Kind of fsync() policy */
585 char *aof_filename
; /* Name of the AOF file */
586 int aof_no_fsync_on_rewrite
; /* Don't fsync if a rewrite is in prog. */
587 int aof_rewrite_perc
; /* Rewrite AOF if % growth is > M and... */
588 off_t aof_rewrite_min_size
; /* the AOF file is at least N bytes. */
589 off_t aof_rewrite_base_size
; /* AOF size on latest startup or rewrite. */
590 off_t aof_current_size
; /* AOF current size. */
591 int aof_rewrite_scheduled
; /* Rewrite once BGSAVE terminates. */
592 pid_t aof_child_pid
; /* PID if rewriting process */
593 sds aof_rewrite_buf
; /* buffer taken by parent during oppend only rewrite */
594 sds aof_buf
; /* AOF buffer, written before entering the event loop */
595 int aof_fd
; /* File descriptor of currently selected AOF file */
596 int aof_selected_db
; /* Currently selected DB in AOF */
597 time_t aof_flush_postponed_start
; /* UNIX time of postponed AOF flush */
598 time_t aof_last_fsync
; /* UNIX time of last fsync() */
599 /* RDB persistence */
600 long long dirty
; /* Changes to DB from the last save */
601 long long dirty_before_bgsave
; /* Used to restore dirty on failed BGSAVE */
602 pid_t rdb_child_pid
; /* PID of RDB saving child */
603 struct saveparam
*saveparams
; /* Save points array for RDB */
604 int saveparamslen
; /* Number of saving points */
605 char *rdb_filename
; /* Name of RDB file */
606 int rdb_compression
; /* Use compression in RDB? */
608 char *logfile
; /* Path of log file */
609 int syslog_enabled
; /* Is syslog enabled? */
610 char *syslog_ident
; /* Syslog ident */
611 int syslog_facility
; /* Syslog facility */
612 /* Slave specific fields */
613 char *masterauth
; /* AUTH with this password with master */
614 char *masterhost
; /* Hostname of master */
615 int masterport
; /* Port of master */
616 int repl_ping_slave_period
; /* Master pings the salve every N seconds */
617 int repl_timeout
; /* Timeout after N seconds of master idle */
618 redisClient
*master
; /* Client that is master for this slave */
619 int repl_syncio_timeout
; /* Timeout for synchronous I/O calls */
620 int repl_state
; /* Replication status if the instance is a slave */
621 off_t repl_transfer_left
; /* Bytes left reading .rdb */
622 int repl_transfer_s
; /* Slave -> Master SYNC socket */
623 int repl_transfer_fd
; /* Slave -> Master SYNC temp file descriptor */
624 char *repl_transfer_tmpfile
; /* Slave-> master SYNC temp file name */
625 time_t repl_transfer_lastio
; /* Unix time of the latest read, for timeout */
626 int repl_serve_stale_data
; /* Serve stale data when link is down? */
627 time_t repl_down_since
; /* Unix time at which link with master went down */
629 unsigned int maxclients
; /* Max number of simultaneous clients */
630 unsigned long long maxmemory
; /* Max number of memory bytes to use */
631 int maxmemory_policy
; /* Policy for key evition */
632 int maxmemory_samples
; /* Pricision of random sampling */
633 /* Blocked clients */
634 unsigned int bpop_blocked_clients
; /* Number of clients blocked by lists */
635 list
*unblocked_clients
; /* list of clients to unblock before next loop */
636 /* Sort parameters - qsort_r() is only available under BSD so we
637 * have to take this state global, in order to pass it to sortCompare() */
642 /* Zip structure config, see redis.conf for more information */
643 size_t hash_max_zipmap_entries
;
644 size_t hash_max_zipmap_value
;
645 size_t list_max_ziplist_entries
;
646 size_t list_max_ziplist_value
;
647 size_t set_max_intset_entries
;
648 size_t zset_max_ziplist_entries
;
649 size_t zset_max_ziplist_value
;
650 time_t unixtime
; /* Unix time sampled every second. */
652 dict
*pubsub_channels
; /* Map channels to list of subscribed clients */
653 list
*pubsub_patterns
; /* A list of pubsub_patterns */
655 int cluster_enabled
; /* Is cluster enabled? */
656 clusterState cluster
; /* State of the cluster */
658 lua_State
*lua
; /* The Lua interpreter. We use just one for all clients */
659 redisClient
*lua_client
; /* The "fake client" to query Redis from Lua */
660 redisClient
*lua_caller
; /* The client running EVAL right now, or NULL */
661 dict
*lua_scripts
; /* A dictionary of SHA1 -> Lua scripts */
662 long long lua_time_limit
; /* Script timeout in seconds */
663 long long lua_time_start
; /* Start time of script */
664 int lua_write_dirty
; /* True if a write command was called during the
665 execution of the current script. */
666 int lua_random_dirty
; /* True if a random command was called during the
667 execution of the current script. */
668 int lua_timedout
; /* True if we reached the time limit for script
670 int lua_kill
; /* Kill the script if true. */
671 /* Assert & bug reportign */
675 int bug_report_start
; /* True if bug report header was already logged. */
678 typedef struct pubsubPattern
{
683 typedef void redisCommandProc(redisClient
*c
);
684 typedef int *redisGetKeysProc(struct redisCommand
*cmd
, robj
**argv
, int argc
, int *numkeys
, int flags
);
685 struct redisCommand
{
687 redisCommandProc
*proc
;
689 char *sflags
; /* Flags as string represenation, one char per flag. */
690 int flags
; /* The actual flags, obtained from the 'sflags' field. */
691 /* Use a function to determine keys arguments in a command line.
692 * Used for Redis Cluster redirect. */
693 redisGetKeysProc
*getkeys_proc
;
694 /* What keys should be loaded in background when calling this command? */
695 int firstkey
; /* The first argument that's a key (0 = no keys) */
696 int lastkey
; /* THe last argument that's a key */
697 int keystep
; /* The step between first and last key */
698 long long microseconds
, calls
;
701 struct redisFunctionSym
{
703 unsigned long pointer
;
706 typedef struct _redisSortObject
{
714 typedef struct _redisSortOperation
{
717 } redisSortOperation
;
719 /* Structure to hold list iteration abstraction. */
722 unsigned char encoding
;
723 unsigned char direction
; /* Iteration direction */
728 /* Structure for an entry while iterating over a list. */
730 listTypeIterator
*li
;
731 unsigned char *zi
; /* Entry in ziplist */
732 listNode
*ln
; /* Entry in linked list */
735 /* Structure to hold set iteration abstraction. */
739 int ii
; /* intset iterator */
743 /* Structure to hold hash iteration abstration. Note that iteration over
744 * hashes involves both fields and values. Because it is possible that
745 * not both are required, store pointers in the iterator to avoid
746 * unnecessary memory allocation for fields/values. */
750 unsigned char *zk
, *zv
;
751 unsigned int zklen
, zvlen
;
757 #define REDIS_HASH_KEY 1
758 #define REDIS_HASH_VALUE 2
760 /*-----------------------------------------------------------------------------
761 * Extern declarations
762 *----------------------------------------------------------------------------*/
764 extern struct redisServer server
;
765 extern struct sharedObjectsStruct shared
;
766 extern dictType setDictType
;
767 extern dictType zsetDictType
;
768 extern dictType clusterNodesDictType
;
769 extern dictType dbDictType
;
770 extern double R_Zero
, R_PosInf
, R_NegInf
, R_Nan
;
771 dictType hashDictType
;
773 /*-----------------------------------------------------------------------------
774 * Functions prototypes
775 *----------------------------------------------------------------------------*/
778 long long ustime(void);
779 long long mstime(void);
781 /* networking.c -- Networking and Client related operations */
782 redisClient
*createClient(int fd
);
783 void closeTimedoutClients(void);
784 void freeClient(redisClient
*c
);
785 void resetClient(redisClient
*c
);
786 void sendReplyToClient(aeEventLoop
*el
, int fd
, void *privdata
, int mask
);
787 void addReply(redisClient
*c
, robj
*obj
);
788 void *addDeferredMultiBulkLength(redisClient
*c
);
789 void setDeferredMultiBulkLength(redisClient
*c
, void *node
, long length
);
790 void addReplySds(redisClient
*c
, sds s
);
791 void processInputBuffer(redisClient
*c
);
792 void acceptTcpHandler(aeEventLoop
*el
, int fd
, void *privdata
, int mask
);
793 void acceptUnixHandler(aeEventLoop
*el
, int fd
, void *privdata
, int mask
);
794 void readQueryFromClient(aeEventLoop
*el
, int fd
, void *privdata
, int mask
);
795 void addReplyBulk(redisClient
*c
, robj
*obj
);
796 void addReplyBulkCString(redisClient
*c
, char *s
);
797 void addReplyBulkCBuffer(redisClient
*c
, void *p
, size_t len
);
798 void addReplyBulkLongLong(redisClient
*c
, long long ll
);
799 void acceptHandler(aeEventLoop
*el
, int fd
, void *privdata
, int mask
);
800 void addReply(redisClient
*c
, robj
*obj
);
801 void addReplySds(redisClient
*c
, sds s
);
802 void addReplyError(redisClient
*c
, char *err
);
803 void addReplyStatus(redisClient
*c
, char *status
);
804 void addReplyDouble(redisClient
*c
, double d
);
805 void addReplyLongLong(redisClient
*c
, long long ll
);
806 void addReplyMultiBulkLen(redisClient
*c
, long length
);
807 void copyClientOutputBuffer(redisClient
*dst
, redisClient
*src
);
808 void *dupClientReplyValue(void *o
);
809 void getClientsMaxBuffers(unsigned long *longest_output_list
,
810 unsigned long *biggest_input_buffer
);
811 sds
getClientInfoString(redisClient
*client
);
812 sds
getAllClientsInfoString(void);
813 void rewriteClientCommandVector(redisClient
*c
, int argc
, ...);
814 void rewriteClientCommandArgument(redisClient
*c
, int i
, robj
*newval
);
815 unsigned long getClientOutputBufferMemoryUsage(redisClient
*c
);
816 void freeClientsInAsyncFreeQueue(void);
817 void asyncCloseClientOnOutputBufferLimitReached(redisClient
*c
);
818 int getClientLimitClassByName(char *name
);
819 char *getClientLimitClassName(int class);
822 void addReplyErrorFormat(redisClient
*c
, const char *fmt
, ...)
823 __attribute__((format(printf
, 2, 3)));
824 void addReplyStatusFormat(redisClient
*c
, const char *fmt
, ...)
825 __attribute__((format(printf
, 2, 3)));
827 void addReplyErrorFormat(redisClient
*c
, const char *fmt
, ...);
828 void addReplyStatusFormat(redisClient
*c
, const char *fmt
, ...);
832 void listTypeTryConversion(robj
*subject
, robj
*value
);
833 void listTypePush(robj
*subject
, robj
*value
, int where
);
834 robj
*listTypePop(robj
*subject
, int where
);
835 unsigned long listTypeLength(robj
*subject
);
836 listTypeIterator
*listTypeInitIterator(robj
*subject
, long index
, unsigned char direction
);
837 void listTypeReleaseIterator(listTypeIterator
*li
);
838 int listTypeNext(listTypeIterator
*li
, listTypeEntry
*entry
);
839 robj
*listTypeGet(listTypeEntry
*entry
);
840 void listTypeInsert(listTypeEntry
*entry
, robj
*value
, int where
);
841 int listTypeEqual(listTypeEntry
*entry
, robj
*o
);
842 void listTypeDelete(listTypeEntry
*entry
);
843 void listTypeConvert(robj
*subject
, int enc
);
844 void unblockClientWaitingData(redisClient
*c
);
845 int handleClientsWaitingListPush(redisClient
*c
, robj
*key
, robj
*ele
);
846 void popGenericCommand(redisClient
*c
, int where
);
848 /* MULTI/EXEC/WATCH... */
849 void unwatchAllKeys(redisClient
*c
);
850 void initClientMultiState(redisClient
*c
);
851 void freeClientMultiState(redisClient
*c
);
852 void queueMultiCommand(redisClient
*c
);
853 void touchWatchedKey(redisDb
*db
, robj
*key
);
854 void touchWatchedKeysOnFlush(int dbid
);
856 /* Redis object implementation */
857 void decrRefCount(void *o
);
858 void incrRefCount(robj
*o
);
859 robj
*resetRefCount(robj
*obj
);
860 void freeStringObject(robj
*o
);
861 void freeListObject(robj
*o
);
862 void freeSetObject(robj
*o
);
863 void freeZsetObject(robj
*o
);
864 void freeHashObject(robj
*o
);
865 robj
*createObject(int type
, void *ptr
);
866 robj
*createStringObject(char *ptr
, size_t len
);
867 robj
*dupStringObject(robj
*o
);
868 int isObjectRepresentableAsLongLong(robj
*o
, long long *llongval
);
869 robj
*tryObjectEncoding(robj
*o
);
870 robj
*getDecodedObject(robj
*o
);
871 size_t stringObjectLen(robj
*o
);
872 robj
*createStringObjectFromLongLong(long long value
);
873 robj
*createStringObjectFromLongDouble(long double value
);
874 robj
*createListObject(void);
875 robj
*createZiplistObject(void);
876 robj
*createSetObject(void);
877 robj
*createIntsetObject(void);
878 robj
*createHashObject(void);
879 robj
*createZsetObject(void);
880 robj
*createZsetZiplistObject(void);
881 int getLongFromObjectOrReply(redisClient
*c
, robj
*o
, long *target
, const char *msg
);
882 int checkType(redisClient
*c
, robj
*o
, int type
);
883 int getLongLongFromObjectOrReply(redisClient
*c
, robj
*o
, long long *target
, const char *msg
);
884 int getDoubleFromObjectOrReply(redisClient
*c
, robj
*o
, double *target
, const char *msg
);
885 int getLongLongFromObject(robj
*o
, long long *target
);
886 int getLongDoubleFromObject(robj
*o
, long double *target
);
887 int getLongDoubleFromObjectOrReply(redisClient
*c
, robj
*o
, long double *target
, const char *msg
);
888 char *strEncoding(int encoding
);
889 int compareStringObjects(robj
*a
, robj
*b
);
890 int equalStringObjects(robj
*a
, robj
*b
);
891 unsigned long estimateObjectIdleTime(robj
*o
);
893 /* Synchronous I/O with timeout */
894 int syncWrite(int fd
, char *ptr
, ssize_t size
, int timeout
);
895 int syncRead(int fd
, char *ptr
, ssize_t size
, int timeout
);
896 int syncReadLine(int fd
, char *ptr
, ssize_t size
, int timeout
);
899 void replicationFeedSlaves(list
*slaves
, int dictid
, robj
**argv
, int argc
);
900 void replicationFeedMonitors(list
*monitors
, int dictid
, robj
**argv
, int argc
);
901 void updateSlavesWaitingBgsave(int bgsaveerr
);
902 void replicationCron(void);
904 /* Generic persistence functions */
905 void startLoading(FILE *fp
);
906 void loadingProgress(off_t pos
);
907 void stopLoading(void);
909 /* RDB persistence */
912 /* AOF persistence */
913 void flushAppendOnlyFile(int force
);
914 void feedAppendOnlyFile(struct redisCommand
*cmd
, int dictid
, robj
**argv
, int argc
);
915 void aofRemoveTempFile(pid_t childpid
);
916 int rewriteAppendOnlyFileBackground(void);
917 int loadAppendOnlyFile(char *filename
);
918 void stopAppendOnly(void);
919 int startAppendOnly(void);
920 void backgroundRewriteDoneHandler(int exitcode
, int bysignal
);
922 /* Sorted sets data type */
924 /* Struct to hold a inclusive/exclusive range spec. */
927 int minex
, maxex
; /* are min or max exclusive? */
930 zskiplist
*zslCreate(void);
931 void zslFree(zskiplist
*zsl
);
932 zskiplistNode
*zslInsert(zskiplist
*zsl
, double score
, robj
*obj
);
933 unsigned char *zzlInsert(unsigned char *zl
, robj
*ele
, double score
);
934 int zslDelete(zskiplist
*zsl
, double score
, robj
*obj
);
935 zskiplistNode
*zslFirstInRange(zskiplist
*zsl
, zrangespec range
);
936 double zzlGetScore(unsigned char *sptr
);
937 void zzlNext(unsigned char *zl
, unsigned char **eptr
, unsigned char **sptr
);
938 void zzlPrev(unsigned char *zl
, unsigned char **eptr
, unsigned char **sptr
);
939 unsigned int zsetLength(robj
*zobj
);
940 void zsetConvert(robj
*zobj
, int encoding
);
943 void freeMemoryIfNeeded(void);
944 int processCommand(redisClient
*c
);
945 void setupSignalHandlers(void);
946 struct redisCommand
*lookupCommand(sds name
);
947 struct redisCommand
*lookupCommandByCString(char *s
);
948 void call(redisClient
*c
, int flags
);
949 int prepareForShutdown();
950 void redisLog(int level
, const char *fmt
, ...);
951 void redisLogRaw(int level
, const char *msg
);
953 void updateDictResizePolicy(void);
954 int htNeedsResize(dict
*dict
);
955 void oom(const char *msg
);
956 void populateCommandTable(void);
957 void resetCommandTableStats(void);
960 robj
*setTypeCreate(robj
*value
);
961 int setTypeAdd(robj
*subject
, robj
*value
);
962 int setTypeRemove(robj
*subject
, robj
*value
);
963 int setTypeIsMember(robj
*subject
, robj
*value
);
964 setTypeIterator
*setTypeInitIterator(robj
*subject
);
965 void setTypeReleaseIterator(setTypeIterator
*si
);
966 int setTypeNext(setTypeIterator
*si
, robj
**objele
, int64_t *llele
);
967 robj
*setTypeNextObject(setTypeIterator
*si
);
968 int setTypeRandomElement(robj
*setobj
, robj
**objele
, int64_t *llele
);
969 unsigned long setTypeSize(robj
*subject
);
970 void setTypeConvert(robj
*subject
, int enc
);
973 void convertToRealHash(robj
*o
);
974 void hashTypeTryConversion(robj
*subject
, robj
**argv
, int start
, int end
);
975 void hashTypeTryObjectEncoding(robj
*subject
, robj
**o1
, robj
**o2
);
976 int hashTypeGet(robj
*o
, robj
*key
, robj
**objval
, unsigned char **v
, unsigned int *vlen
);
977 robj
*hashTypeGetObject(robj
*o
, robj
*key
);
978 int hashTypeExists(robj
*o
, robj
*key
);
979 int hashTypeSet(robj
*o
, robj
*key
, robj
*value
);
980 int hashTypeDelete(robj
*o
, robj
*key
);
981 unsigned long hashTypeLength(robj
*o
);
982 hashTypeIterator
*hashTypeInitIterator(robj
*subject
);
983 void hashTypeReleaseIterator(hashTypeIterator
*hi
);
984 int hashTypeNext(hashTypeIterator
*hi
);
985 int hashTypeCurrent(hashTypeIterator
*hi
, int what
, robj
**objval
, unsigned char **v
, unsigned int *vlen
);
986 robj
*hashTypeCurrentObject(hashTypeIterator
*hi
, int what
);
987 robj
*hashTypeLookupWriteOrCreate(redisClient
*c
, robj
*key
);
990 int pubsubUnsubscribeAllChannels(redisClient
*c
, int notify
);
991 int pubsubUnsubscribeAllPatterns(redisClient
*c
, int notify
);
992 void freePubsubPattern(void *p
);
993 int listMatchPubsubPattern(void *a
, void *b
);
994 int pubsubPublishMessage(robj
*channel
, robj
*message
);
997 void loadServerConfig(char *filename
, char *options
);
998 void appendServerSaveParams(time_t seconds
, int changes
);
999 void resetServerSaveParams();
1001 /* db.c -- Keyspace access API */
1002 int removeExpire(redisDb
*db
, robj
*key
);
1003 void propagateExpire(redisDb
*db
, robj
*key
);
1004 int expireIfNeeded(redisDb
*db
, robj
*key
);
1005 long long getExpire(redisDb
*db
, robj
*key
);
1006 void setExpire(redisDb
*db
, robj
*key
, long long when
);
1007 robj
*lookupKey(redisDb
*db
, robj
*key
);
1008 robj
*lookupKeyRead(redisDb
*db
, robj
*key
);
1009 robj
*lookupKeyWrite(redisDb
*db
, robj
*key
);
1010 robj
*lookupKeyReadOrReply(redisClient
*c
, robj
*key
, robj
*reply
);
1011 robj
*lookupKeyWriteOrReply(redisClient
*c
, robj
*key
, robj
*reply
);
1012 void dbAdd(redisDb
*db
, robj
*key
, robj
*val
);
1013 void dbOverwrite(redisDb
*db
, robj
*key
, robj
*val
);
1014 void setKey(redisDb
*db
, robj
*key
, robj
*val
);
1015 int dbExists(redisDb
*db
, robj
*key
);
1016 robj
*dbRandomKey(redisDb
*db
);
1017 int dbDelete(redisDb
*db
, robj
*key
);
1018 long long emptyDb();
1019 int selectDb(redisClient
*c
, int id
);
1020 void signalModifiedKey(redisDb
*db
, robj
*key
);
1021 void signalFlushedDb(int dbid
);
1022 unsigned int GetKeysInSlot(unsigned int hashslot
, robj
**keys
, unsigned int count
);
1024 /* API to get key arguments from commands */
1025 #define REDIS_GETKEYS_ALL 0
1026 #define REDIS_GETKEYS_PRELOAD 1
1027 int *getKeysFromCommand(struct redisCommand
*cmd
, robj
**argv
, int argc
, int *numkeys
, int flags
);
1028 void getKeysFreeResult(int *result
);
1029 int *noPreloadGetKeys(struct redisCommand
*cmd
,robj
**argv
, int argc
, int *numkeys
, int flags
);
1030 int *renameGetKeys(struct redisCommand
*cmd
,robj
**argv
, int argc
, int *numkeys
, int flags
);
1031 int *zunionInterGetKeys(struct redisCommand
*cmd
,robj
**argv
, int argc
, int *numkeys
, int flags
);
1034 void clusterInit(void);
1035 unsigned short crc16(const char *buf
, int len
);
1036 unsigned int keyHashSlot(char *key
, int keylen
);
1037 clusterNode
*createClusterNode(char *nodename
, int flags
);
1038 int clusterAddNode(clusterNode
*node
);
1039 void clusterCron(void);
1040 clusterNode
*getNodeByQuery(redisClient
*c
, struct redisCommand
*cmd
, robj
**argv
, int argc
, int *hashslot
, int *ask
);
1041 void clusterPropagatePublish(robj
*channel
, robj
*message
);
1044 void scriptingInit(void);
1047 char *redisGitSHA1(void);
1048 char *redisGitDirty(void);
1050 /* Commands prototypes */
1051 void authCommand(redisClient
*c
);
1052 void pingCommand(redisClient
*c
);
1053 void echoCommand(redisClient
*c
);
1054 void setCommand(redisClient
*c
);
1055 void setnxCommand(redisClient
*c
);
1056 void setexCommand(redisClient
*c
);
1057 void psetexCommand(redisClient
*c
);
1058 void getCommand(redisClient
*c
);
1059 void delCommand(redisClient
*c
);
1060 void existsCommand(redisClient
*c
);
1061 void setbitCommand(redisClient
*c
);
1062 void getbitCommand(redisClient
*c
);
1063 void setrangeCommand(redisClient
*c
);
1064 void getrangeCommand(redisClient
*c
);
1065 void incrCommand(redisClient
*c
);
1066 void decrCommand(redisClient
*c
);
1067 void incrbyCommand(redisClient
*c
);
1068 void decrbyCommand(redisClient
*c
);
1069 void incrbyfloatCommand(redisClient
*c
);
1070 void selectCommand(redisClient
*c
);
1071 void randomkeyCommand(redisClient
*c
);
1072 void keysCommand(redisClient
*c
);
1073 void dbsizeCommand(redisClient
*c
);
1074 void lastsaveCommand(redisClient
*c
);
1075 void saveCommand(redisClient
*c
);
1076 void bgsaveCommand(redisClient
*c
);
1077 void bgrewriteaofCommand(redisClient
*c
);
1078 void shutdownCommand(redisClient
*c
);
1079 void moveCommand(redisClient
*c
);
1080 void renameCommand(redisClient
*c
);
1081 void renamenxCommand(redisClient
*c
);
1082 void lpushCommand(redisClient
*c
);
1083 void rpushCommand(redisClient
*c
);
1084 void lpushxCommand(redisClient
*c
);
1085 void rpushxCommand(redisClient
*c
);
1086 void linsertCommand(redisClient
*c
);
1087 void lpopCommand(redisClient
*c
);
1088 void rpopCommand(redisClient
*c
);
1089 void llenCommand(redisClient
*c
);
1090 void lindexCommand(redisClient
*c
);
1091 void lrangeCommand(redisClient
*c
);
1092 void ltrimCommand(redisClient
*c
);
1093 void typeCommand(redisClient
*c
);
1094 void lsetCommand(redisClient
*c
);
1095 void saddCommand(redisClient
*c
);
1096 void sremCommand(redisClient
*c
);
1097 void smoveCommand(redisClient
*c
);
1098 void sismemberCommand(redisClient
*c
);
1099 void scardCommand(redisClient
*c
);
1100 void spopCommand(redisClient
*c
);
1101 void srandmemberCommand(redisClient
*c
);
1102 void sinterCommand(redisClient
*c
);
1103 void sinterstoreCommand(redisClient
*c
);
1104 void sunionCommand(redisClient
*c
);
1105 void sunionstoreCommand(redisClient
*c
);
1106 void sdiffCommand(redisClient
*c
);
1107 void sdiffstoreCommand(redisClient
*c
);
1108 void syncCommand(redisClient
*c
);
1109 void flushdbCommand(redisClient
*c
);
1110 void flushallCommand(redisClient
*c
);
1111 void sortCommand(redisClient
*c
);
1112 void lremCommand(redisClient
*c
);
1113 void rpoplpushCommand(redisClient
*c
);
1114 void infoCommand(redisClient
*c
);
1115 void mgetCommand(redisClient
*c
);
1116 void monitorCommand(redisClient
*c
);
1117 void expireCommand(redisClient
*c
);
1118 void expireatCommand(redisClient
*c
);
1119 void pexpireCommand(redisClient
*c
);
1120 void pexpireatCommand(redisClient
*c
);
1121 void getsetCommand(redisClient
*c
);
1122 void ttlCommand(redisClient
*c
);
1123 void pttlCommand(redisClient
*c
);
1124 void persistCommand(redisClient
*c
);
1125 void slaveofCommand(redisClient
*c
);
1126 void debugCommand(redisClient
*c
);
1127 void msetCommand(redisClient
*c
);
1128 void msetnxCommand(redisClient
*c
);
1129 void zaddCommand(redisClient
*c
);
1130 void zincrbyCommand(redisClient
*c
);
1131 void zrangeCommand(redisClient
*c
);
1132 void zrangebyscoreCommand(redisClient
*c
);
1133 void zrevrangebyscoreCommand(redisClient
*c
);
1134 void zcountCommand(redisClient
*c
);
1135 void zrevrangeCommand(redisClient
*c
);
1136 void zcardCommand(redisClient
*c
);
1137 void zremCommand(redisClient
*c
);
1138 void zscoreCommand(redisClient
*c
);
1139 void zremrangebyscoreCommand(redisClient
*c
);
1140 void multiCommand(redisClient
*c
);
1141 void execCommand(redisClient
*c
);
1142 void discardCommand(redisClient
*c
);
1143 void blpopCommand(redisClient
*c
);
1144 void brpopCommand(redisClient
*c
);
1145 void brpoplpushCommand(redisClient
*c
);
1146 void appendCommand(redisClient
*c
);
1147 void strlenCommand(redisClient
*c
);
1148 void zrankCommand(redisClient
*c
);
1149 void zrevrankCommand(redisClient
*c
);
1150 void hsetCommand(redisClient
*c
);
1151 void hsetnxCommand(redisClient
*c
);
1152 void hgetCommand(redisClient
*c
);
1153 void hmsetCommand(redisClient
*c
);
1154 void hmgetCommand(redisClient
*c
);
1155 void hdelCommand(redisClient
*c
);
1156 void hlenCommand(redisClient
*c
);
1157 void zremrangebyrankCommand(redisClient
*c
);
1158 void zunionstoreCommand(redisClient
*c
);
1159 void zinterstoreCommand(redisClient
*c
);
1160 void hkeysCommand(redisClient
*c
);
1161 void hvalsCommand(redisClient
*c
);
1162 void hgetallCommand(redisClient
*c
);
1163 void hexistsCommand(redisClient
*c
);
1164 void configCommand(redisClient
*c
);
1165 void hincrbyCommand(redisClient
*c
);
1166 void hincrbyfloatCommand(redisClient
*c
);
1167 void subscribeCommand(redisClient
*c
);
1168 void unsubscribeCommand(redisClient
*c
);
1169 void psubscribeCommand(redisClient
*c
);
1170 void punsubscribeCommand(redisClient
*c
);
1171 void publishCommand(redisClient
*c
);
1172 void watchCommand(redisClient
*c
);
1173 void unwatchCommand(redisClient
*c
);
1174 void clusterCommand(redisClient
*c
);
1175 void restoreCommand(redisClient
*c
);
1176 void migrateCommand(redisClient
*c
);
1177 void askingCommand(redisClient
*c
);
1178 void dumpCommand(redisClient
*c
);
1179 void objectCommand(redisClient
*c
);
1180 void clientCommand(redisClient
*c
);
1181 void evalCommand(redisClient
*c
);
1182 void evalShaCommand(redisClient
*c
);
1183 void scriptCommand(redisClient
*c
);
1185 #if defined(__GNUC__)
1186 void *calloc(size_t count
, size_t size
) __attribute__ ((deprecated
));
1187 void free(void *ptr
) __attribute__ ((deprecated
));
1188 void *malloc(size_t size
) __attribute__ ((deprecated
));
1189 void *realloc(void *ptr
, size_t size
) __attribute__ ((deprecated
));
1192 /* Debugging stuff */
1193 void _redisAssertWithInfo(redisClient
*c
, robj
*o
, char *estr
, char *file
, int line
);
1194 void _redisAssert(char *estr
, char *file
, int line
);
1195 void _redisPanic(char *msg
, char *file
, int line
);
1196 void bugReportStart(void);
1197 void redisLogObjectDebugInfo(robj
*o
);
1198 void sigsegvHandler(int sig
, siginfo_t
*info
, void *secret
);
1199 sds
genRedisInfoString(char *section
);