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
054ed87d
Commit
054ed87d
authored
Jun 09, 2011
by
antirez
Browse files
removed no longer useful files from utils directory
parent
8dcec3bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
utils/build-static-symbols.tcl
deleted
100644 → 0
View file @
8dcec3bf
# Build a symbol table for static symbols of redis.c
# Useful to get stack traces on segfault without a debugger. See redis.c
# for more information.
#
# Copyright
(
C
)
2009 Salvatore Sanfilippo, under the BSD license.
set fd
[
open redis.c
]
set symlist
{}
while
{[
gets $fd line
]
!= -1
}
{
if
{[
regexp
{
^static +
[
A-z0-9
]
+
[
*
]
+
([
A-z0-9
]
*
)
\(
}
$line - sym
]}
{
lappend symlist $sym
}
}
set symlist
[
lsort -unique $symlist
]
puts
"static struct redisFunctionSym symsTable
\[\]
= {"
foreach sym $symlist
{
puts
"{
\"
$sym
\"
,(unsigned long)
$sym
},"
}
puts
"{NULL,0}"
puts
"};"
close $fd
utils/redis-copy.rb
deleted
100644 → 0
View file @
8dcec3bf
# redis-copy.rb - Copyright (C) 2009-2010 Salvatore Sanfilippo
# BSD license, See the COPYING file for more information.
#
# Copy the whole dataset from one Redis instance to another one
#
# WARNING: currently hashes and sorted sets are not supported! This
# program should be updated.
require
'rubygems'
require
'redis'
require
'digest/sha1'
def
redisCopy
(
opts
=
{})
sha1
=
""
src
=
Redis
.
new
(
:host
=>
opts
[
:srchost
],
:port
=>
opts
[
:srcport
])
dst
=
Redis
.
new
(
:host
=>
opts
[
:dsthost
],
:port
=>
opts
[
:dstport
])
puts
"Loading key names..."
keys
=
src
.
keys
(
'*'
)
puts
"Copying
#{
keys
.
length
}
keys..."
c
=
0
keys
.
each
{
|
k
|
vtype
=
src
.
type?
(
k
)
ttl
=
src
.
ttl
(
k
).
to_i
if
vtype
!=
"none"
if
vtype
==
"string"
dst
[
k
]
=
src
[
k
]
elsif
vtype
==
"list"
list
=
src
.
lrange
(
k
,
0
,
-
1
)
if
list
.
length
==
0
# Empty list special case
dst
.
lpush
(
k
,
""
)
dst
.
lpop
(
k
)
else
list
.
each
{
|
ele
|
dst
.
rpush
(
k
,
ele
)
}
end
elsif
vtype
==
"set"
set
=
src
.
smembers
(
k
)
if
set
.
length
==
0
# Empty set special case
dst
.
sadd
(
k
,
""
)
dst
.
srem
(
k
,
""
)
else
set
.
each
{
|
ele
|
dst
.
sadd
(
k
,
ele
)
}
end
elsif
vtype
==
"none"
puts
"WARNING: key '
#{
k
}
' was removed in the meanwhile."
end
# Handle keys with an expire time set
if
ttl
!=
-
1
and
vtype
!=
"none"
dst
.
expire
(
k
,
ttl
)
end
c
=
c
+
1
if
(
c
%
1000
)
==
0
puts
"
#{
c
}
/
#{
keys
.
length
}
completed"
end
}
puts
"DONE!"
end
if
ARGV
.
length
!=
4
puts
"Usage: redis-copy.rb <srchost> <srcport> <dsthost> <dstport>"
exit
1
end
puts
"WARNING: it's up to you to FLUSHDB the destination host before to continue, press any key when ready."
STDIN
.
gets
srchost
=
ARGV
[
0
]
srcport
=
ARGV
[
1
]
dsthost
=
ARGV
[
2
]
dstport
=
ARGV
[
3
]
puts
"Copying
#{
srchost
}
:
#{
srcport
}
into
#{
dsthost
}
:
#{
dstport
}
"
redisCopy
(
:srchost
=>
srchost
,
:srcport
=>
srcport
.
to_i
,
:dsthost
=>
dsthost
,
:dstport
=>
dstport
.
to_i
)
utils/redis-sha1.rb
deleted
100644 → 0
View file @
8dcec3bf
# redis-sha1.rb - Copyright (C) 2009 Salvatore Sanfilippo
# BSD license, See the COPYING file for more information.
#
# Performs the SHA1 sum of the whole datset.
# This is useful to spot bugs in persistence related code and to make sure
# Slaves and Masters are in SYNC.
#
# If you hack this code make sure to sort keys and set elements as this are
# unsorted elements. Otherwise the sum may differ with equal dataset.
require
'rubygems'
require
'redis'
require
'digest/sha1'
def
redisSha1
(
opts
=
{})
sha1
=
""
r
=
Redis
.
new
(
opts
)
r
.
keys
(
'*'
).
sort
.
each
{
|
k
|
vtype
=
r
.
type?
(
k
)
if
vtype
==
"string"
len
=
1
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
k
)
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
r
.
get
(
k
))
elsif
vtype
==
"list"
len
=
r
.
llen
(
k
)
if
len
!=
0
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
k
)
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
r
.
list_range
(
k
,
0
,
-
1
).
join
(
"
\x01
"
))
end
elsif
vtype
==
"set"
len
=
r
.
scard
(
k
)
if
len
!=
0
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
k
)
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
r
.
set_members
(
k
).
to_a
.
sort
.
join
(
"
\x02
"
))
end
elsif
vtype
==
"zset"
len
=
r
.
zcard
(
k
)
if
len
!=
0
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
k
)
sha1
=
Digest
::
SHA1
.
hexdigest
(
sha1
+
r
.
zrange
(
k
,
0
,
-
1
).
join
(
"
\x01
"
))
end
end
# puts "#{k} => #{sha1}" if len != 0
}
sha1
end
host
=
ARGV
[
0
]
||
"127.0.0.1"
port
=
ARGV
[
1
]
||
"6379"
db
=
ARGV
[
2
]
||
"0"
puts
"Performing SHA1 of Redis server
#{
host
}
#{
port
}
DB:
#{
db
}
"
p
"Dataset SHA1:
#{
redisSha1
(
:host
=>
host
,
:port
=>
port
.
to_i
,
:db
=>
db
)
}
"
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