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
99c2fe0b
Commit
99c2fe0b
authored
Mar 21, 2019
by
Dvir Volk
Browse files
added special flag for keyspace miss notifications
parent
8620a434
Changes
5
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
99c2fe0b
...
...
@@ -107,7 +107,7 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) {
* to return NULL ASAP. */
if
(
server
.
masterhost
==
NULL
)
{
server
.
stat_keyspace_misses
++
;
notifyKeyspaceEvent
(
NOTIFY_
GENERIC
,
"miss"
,
key
,
db
->
id
);
notifyKeyspaceEvent
(
NOTIFY_
KEY_MISS
,
"miss"
,
key
,
db
->
id
);
return
NULL
;
}
...
...
@@ -129,14 +129,14 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) {
server
.
current_client
->
cmd
->
flags
&
CMD_READONLY
)
{
server
.
stat_keyspace_misses
++
;
notifyKeyspaceEvent
(
NOTIFY_
GENERIC
,
"miss"
,
key
,
db
->
id
);
notifyKeyspaceEvent
(
NOTIFY_
KEY_MISS
,
"miss"
,
key
,
db
->
id
);
return
NULL
;
}
}
val
=
lookupKey
(
db
,
key
,
flags
);
if
(
val
==
NULL
)
{
server
.
stat_keyspace_misses
++
;
notifyKeyspaceEvent
(
NOTIFY_
GENERIC
,
"miss"
,
key
,
db
->
id
);
notifyKeyspaceEvent
(
NOTIFY_
KEY_MISS
,
"miss"
,
key
,
db
->
id
);
}
else
server
.
stat_keyspace_hits
++
;
...
...
src/modules/testmodule.c
View file @
99c2fe0b
...
...
@@ -450,7 +450,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
REDISMODULE_NOTIFY_HASH
|
REDISMODULE_NOTIFY_SET
|
REDISMODULE_NOTIFY_STRING
|
REDISMODULE_NOTIFY_
GENERIC
,
REDISMODULE_NOTIFY_
KEY_MISS
,
NotifyCallback
);
if
(
RedisModule_CreateCommand
(
ctx
,
"test.notify"
,
TestNotifications
,
"write deny-oom"
,
1
,
1
,
1
)
==
REDISMODULE_ERR
)
...
...
src/notify.c
View file @
99c2fe0b
...
...
@@ -55,6 +55,7 @@ int keyspaceEventsStringToFlags(char *classes) {
case
'K'
:
flags
|=
NOTIFY_KEYSPACE
;
break
;
case
'E'
:
flags
|=
NOTIFY_KEYEVENT
;
break
;
case
't'
:
flags
|=
NOTIFY_STREAM
;
break
;
case
'm'
:
flags
|=
NOTIFY_KEY_MISS
;
break
;
default:
return
-
1
;
}
}
...
...
@@ -81,6 +82,7 @@ sds keyspaceEventsFlagsToString(int flags) {
if
(
flags
&
NOTIFY_EXPIRED
)
res
=
sdscatlen
(
res
,
"x"
,
1
);
if
(
flags
&
NOTIFY_EVICTED
)
res
=
sdscatlen
(
res
,
"e"
,
1
);
if
(
flags
&
NOTIFY_STREAM
)
res
=
sdscatlen
(
res
,
"t"
,
1
);
if
(
flags
&
NOTIFY_KEY_MISS
)
res
=
sdscatlen
(
res
,
"m"
,
1
);
}
if
(
flags
&
NOTIFY_KEYSPACE
)
res
=
sdscatlen
(
res
,
"K"
,
1
);
if
(
flags
&
NOTIFY_KEYEVENT
)
res
=
sdscatlen
(
res
,
"E"
,
1
);
...
...
src/redismodule.h
View file @
99c2fe0b
...
...
@@ -98,6 +98,7 @@
#define REDISMODULE_NOTIFY_EXPIRED (1<<8)
/* x */
#define REDISMODULE_NOTIFY_EVICTED (1<<9)
/* e */
#define REDISMODULE_NOTIFY_STREAM (1<<10)
/* t */
#define REDISMODULE_NOTIFY_KEY_MISS (1<<11)
/* m */
#define REDISMODULE_NOTIFY_ALL (REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_STRING | REDISMODULE_NOTIFY_LIST | REDISMODULE_NOTIFY_SET | REDISMODULE_NOTIFY_HASH | REDISMODULE_NOTIFY_ZSET | REDISMODULE_NOTIFY_EXPIRED | REDISMODULE_NOTIFY_EVICTED | REDISMODULE_NOTIFY_STREAM)
/* A */
...
...
src/server.h
View file @
99c2fe0b
...
...
@@ -468,7 +468,9 @@ typedef long long mstime_t; /* millisecond time type. */
#define NOTIFY_EXPIRED (1<<8)
/* x */
#define NOTIFY_EVICTED (1<<9)
/* e */
#define NOTIFY_STREAM (1<<10)
/* t */
#define NOTIFY_ALL (NOTIFY_GENERIC | NOTIFY_STRING | NOTIFY_LIST | NOTIFY_SET | NOTIFY_HASH | NOTIFY_ZSET | NOTIFY_EXPIRED | NOTIFY_EVICTED | NOTIFY_STREAM)
/* A flag */
#define NOTIFY_KEY_MISS (1<<11)
/* m */
#define NOTIFY_ALL (NOTIFY_GENERIC | NOTIFY_STRING | NOTIFY_LIST | NOTIFY_SET | NOTIFY_HASH | NOTIFY_ZSET | NOTIFY_EXPIRED | NOTIFY_EVICTED | NOTIFY_STREAM | NOTIFY_KEY_MISS)
/* A flag */
/* Get the first bind addr or NULL */
#define NET_FIRST_BIND_ADDR (server.bindaddr_count ? server.bindaddr[0] : NULL)
...
...
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