mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 08:00:49 +00:00
Use the RDB info fields to provide info to users.
Fix #5790 and 5878. Maybe a better option was to have such fields named with the first byte '%' as those are info fields for specification, however now to break it in a backward incompatible way is not an option, so let's use the fields actively to provide info when sensible, otherwise ignore when they are not really helpful.
This commit is contained in:
parent
ab1e87f5b1
commit
b9b140e2e2
21
src/rdb.c
21
src/rdb.c
@ -1872,7 +1872,7 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
||||
/* Key-specific attributes, set by opcodes before the key type. */
|
||||
long long lru_idle = -1, lfu_freq = -1, expiretime = -1, now = mstime();
|
||||
long long lru_clock = LRU_CLOCK();
|
||||
|
||||
|
||||
while(1) {
|
||||
robj *key, *val;
|
||||
|
||||
@ -1963,6 +1963,23 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
||||
"Can't load Lua script from RDB file! "
|
||||
"BODY: %s", auxval->ptr);
|
||||
}
|
||||
} else if (!strcasecmp(auxkey->ptr,"redis-ver")) {
|
||||
serverLog(LL_NOTICE,"Loading RDB produced by version %s",
|
||||
auxval->ptr);
|
||||
} else if (!strcasecmp(auxkey->ptr,"ctime")) {
|
||||
time_t age = time(NULL)-strtol(auxval->ptr,NULL,10);
|
||||
if (age < 0) age = 0;
|
||||
serverLog(LL_NOTICE,"RDB age %ld seconds",
|
||||
(unsigned long) age);
|
||||
} else if (!strcasecmp(auxkey->ptr,"used-mem")) {
|
||||
long long usedmem = strtoll(auxval->ptr,NULL,10);
|
||||
serverLog(LL_NOTICE,"RDB memory usage when created %.2f Mb",
|
||||
(double) usedmem / (1024*1024));
|
||||
} else if (!strcasecmp(auxkey->ptr,"aof-preamble")) {
|
||||
long long haspreamble = strtoll(auxval->ptr,NULL,10);
|
||||
if (haspreamble) serverLog(LL_NOTICE,"RDB has an AOF tail");
|
||||
} else if (!strcasecmp(auxkey->ptr,"redis-bits")) {
|
||||
/* Just ignored. */
|
||||
} else {
|
||||
/* We ignore fields we don't understand, as by AUX field
|
||||
* contract. */
|
||||
@ -2021,7 +2038,7 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
||||
|
||||
/* Set the expire time if needed */
|
||||
if (expiretime != -1) setExpire(NULL,db,key,expiretime);
|
||||
|
||||
|
||||
/* Set usage information (for eviction). */
|
||||
objectSetLRUOrLFU(val,lfu_freq,lru_idle,lru_clock);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user