X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/7c0e1b53c4c4f646c788fcd09666e1c321c1d134..21d3294c7013a4385aebd84436394bb58e273093:/src/redis.h diff --git a/src/redis.h b/src/redis.h index 5506e365..5934b6a6 100644 --- a/src/redis.h +++ b/src/redis.h @@ -30,6 +30,7 @@ #include "ziplist.h" /* Compact list data structure */ #include "intset.h" /* Compact integer set structure */ #include "version.h" +#include "util.h" /* Error codes */ #define REDIS_OK 0 @@ -367,6 +368,28 @@ struct sharedObjectsStruct { *integers[REDIS_SHARED_INTEGERS]; }; +/* ZSETs use a specialized version of Skiplists */ +typedef struct zskiplistNode { + robj *obj; + double score; + struct zskiplistNode *backward; + struct zskiplistLevel { + struct zskiplistNode *forward; + unsigned int span; + } level[]; +} zskiplistNode; + +typedef struct zskiplist { + struct zskiplistNode *header, *tail; + unsigned long length; + int level; +} zskiplist; + +typedef struct zset { + dict *dict; + zskiplist *zsl; +} zset; + /*----------------------------------------------------------------------------- * Redis cluster data structures *----------------------------------------------------------------------------*/ @@ -425,6 +448,7 @@ typedef struct { clusterNode *migrating_slots_to[REDIS_CLUSTER_SLOTS]; clusterNode *importing_slots_from[REDIS_CLUSTER_SLOTS]; clusterNode *slots[REDIS_CLUSTER_SLOTS]; + zskiplist *slots_to_keys; } clusterState; /* Redis cluster messages header */ @@ -518,6 +542,7 @@ struct redisServer { long long stat_evictedkeys; /* number of evicted keys (maxmemory) */ long long stat_keyspace_hits; /* number of successful lookups of keys */ long long stat_keyspace_misses; /* number of failed lookups of keys */ + size_t stat_peak_memory; /* max used memory record */ /* Configuration */ int verbosity; int maxidletime; @@ -626,6 +651,7 @@ struct redisServer { /* Misc */ unsigned lruclock:22; /* clock incrementing every minute, for LRU */ unsigned lruclock_padding:10; + /* Cluster */ int cluster_enabled; clusterState cluster; }; @@ -670,28 +696,6 @@ typedef struct _redisSortOperation { robj *pattern; } redisSortOperation; -/* ZSETs use a specialized version of Skiplists */ -typedef struct zskiplistNode { - robj *obj; - double score; - struct zskiplistNode *backward; - struct zskiplistLevel { - struct zskiplistNode *forward; - unsigned int span; - } level[]; -} zskiplistNode; - -typedef struct zskiplist { - struct zskiplistNode *header, *tail; - unsigned long length; - int level; -} zskiplist; - -typedef struct zset { - dict *dict; - zskiplist *zsl; -} zset; - /* DIsk store threaded I/O request message */ #define REDIS_IOJOB_LOAD 0 #define REDIS_IOJOB_SAVE 1 @@ -849,6 +853,7 @@ void freeHashObject(robj *o); robj *createObject(int type, void *ptr); robj *createStringObject(char *ptr, size_t len); robj *dupStringObject(robj *o); +int isObjectRepresentableAsLongLong(robj *o, long long *llongval); robj *tryObjectEncoding(robj *o); robj *getDecodedObject(robj *o); size_t stringObjectLen(robj *o); @@ -920,10 +925,19 @@ int startAppendOnly(void); void backgroundRewriteDoneHandler(int exitcode, int bysignal); /* Sorted sets data type */ + +/* Struct to hold a inclusive/exclusive range spec. */ +typedef struct { + double min, max; + int minex, maxex; /* are min or max exclusive? */ +} zrangespec; + zskiplist *zslCreate(void); void zslFree(zskiplist *zsl); zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj); unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score); +int zslDelete(zskiplist *zsl, double score, robj *obj); +zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec range); double zzlGetScore(unsigned char *sptr); void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr); void zzlPrev(unsigned char *zl, unsigned char **eptr, unsigned char **sptr); @@ -1016,18 +1030,6 @@ int pubsubUnsubscribeAllPatterns(redisClient *c, int notify); void freePubsubPattern(void *p); int listMatchPubsubPattern(void *a, void *b); -/* Utility functions */ -int stringmatchlen(const char *pattern, int patternLen, - const char *string, int stringLen, int nocase); -int stringmatch(const char *pattern, const char *string, int nocase); -long long memtoll(const char *p, int *err); -int ll2string(char *s, size_t len, long long value); -int string2ll(char *s, size_t len, long long *value); -int d2string(char *s, size_t len, double value); -int isStringRepresentableAsLong(sds s, long *longval); -int isStringRepresentableAsLongLong(sds s, long long *longval); -int isObjectRepresentableAsLongLong(robj *o, long long *llongval); - /* Configuration */ void loadServerConfig(char *filename); void appendServerSaveParams(time_t seconds, int changes); @@ -1053,6 +1055,7 @@ long long emptyDb(); int selectDb(redisClient *c, int id); void signalModifiedKey(redisDb *db, robj *key); void signalFlushedDb(int dbid); +unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count); /* API to get key arguments from commands */ #define REDIS_GETKEYS_ALL 0 @@ -1070,7 +1073,7 @@ unsigned int keyHashSlot(char *key, int keylen); clusterNode *createClusterNode(char *nodename, int flags); int clusterAddNode(clusterNode *node); void clusterCron(void); -clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot); +clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask); /* Git SHA1 */ char *redisGitSHA1(void); @@ -1199,6 +1202,7 @@ void restoreCommand(redisClient *c); void migrateCommand(redisClient *c); void dumpCommand(redisClient *c); void objectCommand(redisClient *c); +void clientCommand(redisClient *c); #if defined(__GNUC__) void *calloc(size_t count, size_t size) __attribute__ ((deprecated));