Skip to content

Commit 5ab9e8e

Browse files
committed
* move idb funcs from idb.c to idb_redis.c[h]
* adjust argument order to subkeys [keyPath [pattern [count [skipCount]]]]
1 parent 25a25e8 commit 5ab9e8e

File tree

9 files changed

+643
-530
lines changed

9 files changed

+643
-530
lines changed

README

+16-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Disk Data Storage Features Comparison
1313

1414
Purpose: Redis is a memcache, but can save the memcache data to disk.
1515

16-
* All save to disk even if it is only a changes occurs.
16+
* All save to disk even if it is only a change occurs.
1717
* Support Asynchronous saved only.
1818
* much greater than the memory capacity of the storage will cause problems
1919

@@ -70,11 +70,11 @@ Commands
7070

7171
New commands list here:
7272

73-
* subkeys KeyPath subkeysPattern skipCount Count
73+
* subkeys [KeyPath [subkeysPattern [Count [skipCount]]]]
7474
* the subkeys will iterate all matched subkeys in the keyPath for iDB.
7575
* skipCount: skip the count of matched subkeys before.
7676
* count: return the count of matched subkeys. it should be less than or equ idb-pagesize(if idb-pagesize enabled).
77-
* eg, subkeys "" "" 0 0, will return all the keys in the iDB.
77+
* eg, subkeys, will return all the keys in the iDB if idb-pagesize == 0.
7878
* Note: keys command only return all keys in the memory cache.
7979

8080
Build
@@ -84,17 +84,27 @@ before building, you need ensure cmake installed, and run
8484

8585
git submodule update --init --recursive
8686

87+
88+
if you update the deps/idb/ by git pull, you should make idb too:
89+
90+
cd deps/idb
91+
git checkout master
92+
git pull
93+
make
94+
8795
Todo
8896
-----
8997

98+
* the current dbsize command only for the keys in memcache.
99+
* the most of debug command only for the keys in memcache.
90100
* ![Bug] AOF can not work on iDB. because AOF is still use dict(memcache) to save.
91-
* ![Bug] Replication too.
92-
* List, Set, Hash items should treat as subkey when saving to disk.
101+
* !List, Set, Hash items should treat as subkey when saving to disk.
93102
* Or if items is very large to do so.
103+
* !+ abstract new storage struct for memcache, aof, rdb, disk storage
94104
* Exchange value should be as an atomic operation?
95105
* I use two dicts to keep the changed keys, one is dirtyKeys, another is dirtyQueue. (if asynchronous is enabled.)
96106
* modifies will be added to dirtyKeys if no saving.
97-
* any modifies will be added to dirtyQueue when saving occurs.
107+
* any modifies will be added to dirtyQueue when bgsaving occurs.
98108
* the dirtyKeys will be empty and swap them(dirtyQueue, dirtyKeys) after saving
99109
* maybe it is no problem, after all redis is single thread.
100110

src/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ endif
4747

4848
ifeq ($(uname_S),SunOS)
4949
FINAL_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) -D__EXTENSIONS__ -D_XPG6
50-
FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g -ggdb
50+
FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g3 -ggdb3
5151
FINAL_LIBS= -ldl -lnsl -lsocket -lm -lpthread
52-
DEBUG= -g -ggdb
52+
DEBUG= -g3 -ggdb3
5353
else
5454
FINAL_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
55-
FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g -rdynamic -ggdb
55+
FINAL_LDFLAGS= $(LDFLAGS) $(REDIS_LDFLAGS) -g3 -rdynamic -ggdb3
5656
FINAL_LIBS= -lm -pthread
57-
DEBUG= -g -rdynamic -ggdb
57+
DEBUG= -g3 -rdynamic -ggdb3
5858
endif
5959

6060
# Include paths to dependencies
@@ -99,7 +99,7 @@ endif
9999

100100
REDIS_SERVER_NAME= redis-server
101101
REDIS_SENTINEL_NAME= redis-sentinel
102-
REDIS_SERVER_OBJ= adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o
102+
REDIS_SERVER_OBJ= adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o idb_redis.o
103103
REDIS_CLI_NAME= redis-cli
104104
REDIS_CLI_OBJ= anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o
105105
REDIS_BENCHMARK_NAME= redis-benchmark

src/Makefile.dep

+1
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,4 @@ util.o: util.c fmacros.h util.h
115115
ziplist.o: ziplist.c zmalloc.h util.h ziplist.h endianconv.h config.h
116116
zipmap.o: zipmap.c zmalloc.h endianconv.h config.h
117117
zmalloc.o: zmalloc.c config.h zmalloc.h
118+
idb_redis.o: idb_redis.c idb_redis.h

src/config.c

+24-2
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,19 @@ void loadServerConfigFromString(char *config) {
450450
goto loaderr;
451451
}
452452
} else if (!strcasecmp(argv[0],"idb-path") && argc == 2) {
453-
//sdsfree(server.iDBPath);
453+
/*
454+
long vIDBLocked = iGetInt(server.iDBPath, ".db", 3, ".locked", server.iDBType);
455+
vIDBLocked--;
456+
if (vIDBLocked < 0) vIDBLocked = 0;
457+
iPutInt(server.iDBPath, ".db", 3, vIDBLocked, ".locked", server.iDBType);
458+
*/
454459
server.iDBPath = sdscpy(server.iDBPath, argv[1]);
460+
/*
461+
vIDBLocked = iGetInt(server.iDBPath, ".db", 3, ".locked", server.iDBType);
462+
redisAssert(vIDBLocked == 0);
463+
vIDBLocked++;
464+
iPutInt(server.iDBPath, ".db", 3, vIDBLocked, ".locked", server.iDBType);
465+
*/
455466
} else if (!strcasecmp(argv[0],"idb-enabled") && argc == 2) {
456467
server.iDBEnabled = yesnotoi(argv[1]);
457468
} else if (!strcasecmp(argv[0],"idb-sync") && argc == 2) {
@@ -802,8 +813,19 @@ void configSetCommand(redisClient *c) {
802813
ll <= 0) goto badfmt;
803814
server.iDBType = ll;
804815
} else if (!strcasecmp(c->argv[2]->ptr,"idb-path")) {
805-
//sdsfree(server.iDBPath);
816+
/*
817+
long vIDBLocked = iGetInt(server.iDBPath, ".db", 3, ".locked", server.iDBType);
818+
vIDBLocked--;
819+
if (vIDBLocked < 0) vIDBLocked = 0;
820+
iPutInt(server.iDBPath, ".db", 3, vIDBLocked, ".locked", server.iDBType);
821+
*/
806822
server.iDBPath = sdscpy(server.iDBPath, o->ptr);
823+
/*
824+
vIDBLocked = iGetInt(server.iDBPath, ".db", 3, ".locked", server.iDBType);
825+
redisAssert(vIDBLocked == 0);
826+
vIDBLocked++;
827+
iPutInt(server.iDBPath, ".db", 3, vIDBLocked, ".locked", server.iDBType);
828+
*/
807829
} else if (!strcasecmp(c->argv[2]->ptr,"idb-enabled")) {
808830
server.iDBEnabled = yesnotoi(o->ptr);
809831
} else if (!strcasecmp(c->argv[2]->ptr,"idb-sync")) {

0 commit comments

Comments
 (0)