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
a35ddf12
Commit
a35ddf12
authored
Jan 05, 2010
by
antirez
Browse files
more object-level VM primitives
parent
3a66edc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
a35ddf12
...
...
@@ -487,6 +487,7 @@ static void queueMultiCommand(redisClient *c, struct redisCommand *cmd);
static
void
unblockClient
(
redisClient
*
c
);
static
int
handleClientsWaitingListPush
(
redisClient
*
c
,
robj
*
key
,
robj
*
ele
);
static
void
vmInit
(
void
);
static
void
vmMarkPagesFree
(
off_t
page
,
off_t
count
);
static
void
authCommand
(
redisClient
*
c
);
static
void
pingCommand
(
redisClient
*
c
);
...
...
@@ -836,6 +837,7 @@ static void dictRedisObjectDestructor(void *privdata, void *val)
{
DICT_NOTUSED
(
privdata
);
if
(
val
==
NULL
)
return
;
/* Values of swapped out keys as set to NULL */
decrRefCount
(
val
);
}
...
...
@@ -2320,20 +2322,25 @@ static void freeHashObject(robj *o) {
}
static
void
incrRefCount
(
robj
*
o
)
{
assert
(
!
server
.
vm_enabled
||
o
->
storage
==
REDIS_VM_MEMORY
);
o
->
refcount
++
;
#ifdef DEBUG_REFCOUNT
if
(
o
->
type
==
REDIS_STRING
)
printf
(
"Increment '%s'(%p), now is: %d
\n
"
,
o
->
ptr
,
o
,
o
->
refcount
);
#endif
}
static
void
decrRefCount
(
void
*
obj
)
{
robj
*
o
=
obj
;
#ifdef DEBUG_REFCOUNT
if
(
o
->
type
==
REDIS_STRING
)
printf
(
"Decrement '%s'(%p), now is: %d
\n
"
,
o
->
ptr
,
o
,
o
->
refcount
-
1
);
#endif
/* REDIS_VM_SWAPPED */
if
(
server
.
vm_enabled
&&
o
->
storage
==
REDIS_VM_SWAPPED
)
{
assert
(
o
->
refcount
==
1
);
assert
(
o
->
type
==
REDIS_STRING
);
freeStringObject
(
o
);
vmMarkPagesFree
(
o
->
vm
.
page
,
o
->
vm
.
usedpages
);
if
(
listLength
(
server
.
objfreelist
)
>
REDIS_OBJFREELIST_MAX
||
!
listAddNodeHead
(
server
.
objfreelist
,
o
))
zfree
(
o
);
return
;
}
/* REDIS_VM_MEMORY */
if
(
--
(
o
->
refcount
)
==
0
)
{
switch
(
o
->
type
)
{
case
REDIS_STRING
:
freeStringObject
(
o
);
break
;
...
...
redis.conf
View file @
a35ddf12
...
...
@@ -164,6 +164,10 @@ appendfsync always
# appendfsync everysec
# appendfsync no
################################ VIRTUAL MEMORY ###############################
vm
-
enabled
yes
############################### ADVANCED CONFIG ###############################
# Glue small output buffers together in order to send small replies in a
...
...
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