Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
bf2624ea
Commit
bf2624ea
authored
Sep 15, 2016
by
antirez
Browse files
C struct memoh renamed redisMemOverhead. API prototypes added.
parent
be5439bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/object.c
View file @
bf2624ea
...
@@ -853,40 +853,21 @@ void objectCommand(client *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) {
...
@@ -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
);
...
...
src/server.h
View file @
bf2624ea
...
@@ -769,6 +769,25 @@ typedef struct redisOpArray {
...
@@ -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);
...
@@ -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. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment