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
e00442eb
Commit
e00442eb
authored
Jul 22, 2019
by
antirez
Browse files
Clinet side caching: take count of used caching slots.
parent
bc5cb168
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tracking.c
View file @
e00442eb
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
* use the most significant bits instead of the full 24 bits. */
* use the most significant bits instead of the full 24 bits. */
#define TRACKING_TABLE_SIZE (1<<24)
#define TRACKING_TABLE_SIZE (1<<24)
rax
**
TrackingTable
=
NULL
;
rax
**
TrackingTable
=
NULL
;
unsigned
long
TrackingTableUsedSlots
=
0
;
robj
*
TrackingChannelName
;
robj
*
TrackingChannelName
;
/* Remove the tracking state from the client 'c'. Note that there is not much
/* Remove the tracking state from the client 'c'. Note that there is not much
...
@@ -109,8 +110,10 @@ void trackingRememberKeys(client *c) {
...
@@ -109,8 +110,10 @@ void trackingRememberKeys(client *c) {
sds
sdskey
=
c
->
argv
[
idx
]
->
ptr
;
sds
sdskey
=
c
->
argv
[
idx
]
->
ptr
;
uint64_t
hash
=
crc64
(
0
,
uint64_t
hash
=
crc64
(
0
,
(
unsigned
char
*
)
sdskey
,
sdslen
(
sdskey
))
&
(
TRACKING_TABLE_SIZE
-
1
);
(
unsigned
char
*
)
sdskey
,
sdslen
(
sdskey
))
&
(
TRACKING_TABLE_SIZE
-
1
);
if
(
TrackingTable
[
hash
]
==
NULL
)
if
(
TrackingTable
[
hash
]
==
NULL
)
{
TrackingTable
[
hash
]
=
raxNew
();
TrackingTable
[
hash
]
=
raxNew
();
TrackingTableUsedSlots
++
;
}
raxTryInsert
(
TrackingTable
[
hash
],
raxTryInsert
(
TrackingTable
[
hash
],
(
unsigned
char
*
)
&
c
->
id
,
sizeof
(
c
->
id
),
NULL
,
NULL
);
(
unsigned
char
*
)
&
c
->
id
,
sizeof
(
c
->
id
),
NULL
,
NULL
);
}
}
...
@@ -176,6 +179,7 @@ void trackingInvalidateKey(robj *keyobj) {
...
@@ -176,6 +179,7 @@ void trackingInvalidateKey(robj *keyobj) {
* again if more keys will be modified in this hash slot. */
* again if more keys will be modified in this hash slot. */
raxFree
(
TrackingTable
[
hash
]);
raxFree
(
TrackingTable
[
hash
]);
TrackingTable
[
hash
]
=
NULL
;
TrackingTable
[
hash
]
=
NULL
;
TrackingTableUsedSlots
--
;
}
}
void
trackingInvalidateKeysOnFlush
(
int
dbid
)
{
void
trackingInvalidateKeysOnFlush
(
int
dbid
)
{
...
...
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