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
d0ace5a3
Commit
d0ace5a3
authored
Mar 31, 2012
by
antirez
Browse files
Write RDB magic using a REDIS_RDB_VERSION define that is defined inside rdb.h
parent
609ea084
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/rdb.c
View file @
d0ace5a3
...
@@ -602,6 +602,7 @@ int rdbSave(char *filename) {
...
@@ -602,6 +602,7 @@ int rdbSave(char *filename) {
dictIterator
*
di
=
NULL
;
dictIterator
*
di
=
NULL
;
dictEntry
*
de
;
dictEntry
*
de
;
char
tmpfile
[
256
];
char
tmpfile
[
256
];
char
magic
[
10
];
int
j
;
int
j
;
long
long
now
=
mstime
();
long
long
now
=
mstime
();
FILE
*
fp
;
FILE
*
fp
;
...
@@ -616,7 +617,8 @@ int rdbSave(char *filename) {
...
@@ -616,7 +617,8 @@ int rdbSave(char *filename) {
}
}
rioInitWithFile
(
&
rdb
,
fp
);
rioInitWithFile
(
&
rdb
,
fp
);
if
(
rdbWriteRaw
(
&
rdb
,
"REDIS0004"
,
9
)
==
-
1
)
goto
werr
;
snprintf
(
magic
,
sizeof
(
magic
),
"REDIS%04d"
,
REDIS_RDB_VERSION
);
if
(
rdbWriteRaw
(
&
rdb
,
magic
,
9
)
==
-
1
)
goto
werr
;
for
(
j
=
0
;
j
<
server
.
dbnum
;
j
++
)
{
for
(
j
=
0
;
j
<
server
.
dbnum
;
j
++
)
{
redisDb
*
db
=
server
.
db
+
j
;
redisDb
*
db
=
server
.
db
+
j
;
...
...
src/rdb.h
View file @
d0ace5a3
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
/* TBD: include only necessary headers. */
/* TBD: include only necessary headers. */
#include "redis.h"
#include "redis.h"
/* The current RDB version. When the format changes in a way that is no longer
* backward compatible this number gets incremented. */
#define REDIS_RDB_VERSION 4
/* Defines related to the dump file format. To store 32 bits lengths for short
/* Defines related to the dump file format. To store 32 bits lengths for short
* keys requires a lot of space, so we check the most significant 2 bits of
* keys requires a lot of space, so we check the most significant 2 bits of
* the first byte to interpreter the length:
* the first byte to interpreter the length:
...
...
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