mirror of
https://github.com/fluencelabs/redis
synced 2025-03-25 11:51:03 +00:00
C struct memoh renamed redisMemOverhead. API prototypes added.
This commit is contained in:
parent
be5439bde3
commit
bf2624ea99
33
src/object.c
33
src/object.c
@ -853,40 +853,21 @@ void objectCommand(client *c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This structure is returned by the getMemoryOverheadData() function in
|
|
||||||
* order to return memory overhead information. */
|
|
||||||
struct memoh {
|
|
||||||
size_t total_allocated;
|
|
||||||
size_t startup_allocated;
|
|
||||||
size_t repl_backlog;
|
|
||||||
size_t clients_slaves;
|
|
||||||
size_t clients_normal;
|
|
||||||
size_t aof_buffer;
|
|
||||||
size_t overhead_total;
|
|
||||||
size_t dataset;
|
|
||||||
size_t num_dbs;
|
|
||||||
struct {
|
|
||||||
size_t dbid;
|
|
||||||
size_t overhead_ht_main;
|
|
||||||
size_t overhead_ht_expires;
|
|
||||||
} *db;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Release data obtained with getMemoryOverheadData(). */
|
/* Release data obtained with getMemoryOverheadData(). */
|
||||||
void freeMemoryOverheadData(struct memoh *mh) {
|
void freeMemoryOverheadData(struct redisMemOverhead *mh) {
|
||||||
zfree(mh->db);
|
zfree(mh->db);
|
||||||
zfree(mh);
|
zfree(mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a struct memoh filled with memory overhead information used
|
/* Return a struct redisMemOverhead filled with memory overhead
|
||||||
* for the MEMORY OVERHEAD and INFO command. The returned structure
|
* information used for the MEMORY OVERHEAD and INFO command. The returned
|
||||||
* pointer should be freed calling freeMemoryOverheadData(). */
|
* structure pointer should be freed calling freeMemoryOverheadData(). */
|
||||||
struct memoh *getMemoryOverheadData(void) {
|
struct redisMemOverhead *getMemoryOverheadData(void) {
|
||||||
int j;
|
int j;
|
||||||
size_t mem_total = 0;
|
size_t mem_total = 0;
|
||||||
size_t mem = 0;
|
size_t mem = 0;
|
||||||
size_t zmalloc_used = zmalloc_used_memory();
|
size_t zmalloc_used = zmalloc_used_memory();
|
||||||
struct memoh *mh = zcalloc(sizeof(*mh));
|
struct redisMemOverhead *mh = zcalloc(sizeof(*mh));
|
||||||
|
|
||||||
mh->total_allocated = zmalloc_used;
|
mh->total_allocated = zmalloc_used;
|
||||||
mh->startup_allocated = server.initial_memory_usage;
|
mh->startup_allocated = server.initial_memory_usage;
|
||||||
@ -982,7 +963,7 @@ void memoryCommand(client *c) {
|
|||||||
usage += sizeof(dictEntry);
|
usage += sizeof(dictEntry);
|
||||||
addReplyLongLong(c,usage);
|
addReplyLongLong(c,usage);
|
||||||
} else if (!strcasecmp(c->argv[1]->ptr,"overhead") && c->argc == 2) {
|
} else if (!strcasecmp(c->argv[1]->ptr,"overhead") && c->argc == 2) {
|
||||||
struct memoh *mh = getMemoryOverheadData();
|
struct redisMemOverhead *mh = getMemoryOverheadData();
|
||||||
|
|
||||||
addReplyMultiBulkLen(c,(8+mh->num_dbs)*2);
|
addReplyMultiBulkLen(c,(8+mh->num_dbs)*2);
|
||||||
|
|
||||||
|
21
src/server.h
21
src/server.h
@ -769,6 +769,25 @@ typedef struct redisOpArray {
|
|||||||
int numops;
|
int numops;
|
||||||
} redisOpArray;
|
} redisOpArray;
|
||||||
|
|
||||||
|
/* This structure is returned by the getMemoryOverheadData() function in
|
||||||
|
* order to return memory overhead information. */
|
||||||
|
struct redisMemOverhead {
|
||||||
|
size_t total_allocated;
|
||||||
|
size_t startup_allocated;
|
||||||
|
size_t repl_backlog;
|
||||||
|
size_t clients_slaves;
|
||||||
|
size_t clients_normal;
|
||||||
|
size_t aof_buffer;
|
||||||
|
size_t overhead_total;
|
||||||
|
size_t dataset;
|
||||||
|
size_t num_dbs;
|
||||||
|
struct {
|
||||||
|
size_t dbid;
|
||||||
|
size_t overhead_ht_main;
|
||||||
|
size_t overhead_ht_expires;
|
||||||
|
} *db;
|
||||||
|
};
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
* Global server state
|
* Global server state
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
@ -1481,6 +1500,8 @@ void updateCachedTime(void);
|
|||||||
void resetServerStats(void);
|
void resetServerStats(void);
|
||||||
unsigned int getLRUClock(void);
|
unsigned int getLRUClock(void);
|
||||||
const char *evictPolicyToString(void);
|
const char *evictPolicyToString(void);
|
||||||
|
struct redisMemOverhead *getMemoryOverheadData(void);
|
||||||
|
void freeMemoryOverheadData(struct redisMemOverhead *mh);
|
||||||
|
|
||||||
#define RESTART_SERVER_NONE 0
|
#define RESTART_SERVER_NONE 0
|
||||||
#define RESTART_SERVER_GRACEFULLY (1<<0) /* Do proper shutdown. */
|
#define RESTART_SERVER_GRACEFULLY (1<<0) /* Do proper shutdown. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user