Merge pull request #12 from alibaba/feature-1.2

Feature 1.2
v4
Vinllen Chen 6 years ago committed by GitHub
commit 32012d4f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .gitignore
  2. 5
      ChangeLog
  3. BIN
      bin/redis-shake.darwin64
  4. BIN
      bin/redis-shake.linux64
  5. 10
      src/pkg/rdb/loader.go
  6. 4
      src/pkg/rdb/reader.go
  7. 9
      src/redis-shake/common/utils.go

5
.gitignore vendored

@ -10,8 +10,13 @@ logs
*.yml *.yml
*.pid *.pid
*.tar.gz *.tar.gz
*.log
tags tags
result.db.* result.db.*
bin/*
!/bin/redis-shake.*
conf/*
!conf/redis-shake.conf
dump.data dump.data
runtime.trace runtime.trace

@ -1,6 +1,9 @@
2019-03-27 Alibaba Cloud.
* version: 1.2.1
* IMPROVE: support syncing lua script in RDB syncing.
2019-03-11 Alibaba Cloud. 2019-03-11 Alibaba Cloud.
* version: 1.2.0 * version: 1.2.0
* redis-shake: support 5.0. * IMPROVE: support 5.0.
2019-02-21 Alibaba Cloud. 2019-02-21 Alibaba Cloud.
* version: 1.0.0 * version: 1.0.0
* redis-shake: initial release. * redis-shake: initial release.

Binary file not shown.

Binary file not shown.

@ -121,10 +121,18 @@ func (l *Loader) NextBinEntry() (*BinEntry, error) {
t = rtype t = rtype
} }
switch t { switch t {
case rdbFlagAUX: case RdbFlagAUX:
aux_key, _ := l.ReadString() aux_key, _ := l.ReadString()
aux_value, _ := l.ReadString() aux_value, _ := l.ReadString()
log.Info("Aux information key:", string(aux_key), " value:", string(aux_value)) log.Info("Aux information key:", string(aux_key), " value:", string(aux_value))
if string(aux_key) == "lua" {
// we should handle the lua script
entry.DB = l.db
entry.Key = aux_key
entry.Type = t
entry.Value = aux_value
return entry, nil
}
case rdbFlagResizeDB: case rdbFlagResizeDB:
db_size, _ := l.ReadLength() db_size, _ := l.ReadLength()
expire_size, _ := l.ReadLength() expire_size, _ := l.ReadLength()

@ -36,7 +36,7 @@ const (
RDBTypeStreamListPacks = 15 // stream RDBTypeStreamListPacks = 15 // stream
rdbFlagOnlyValue = 0xf9 rdbFlagOnlyValue = 0xf9
rdbFlagAUX = 0xfa RdbFlagAUX = 0xfa
rdbFlagResizeDB = 0xfb rdbFlagResizeDB = 0xfb
rdbFlagExpiryMS = 0xfc rdbFlagExpiryMS = 0xfc
rdbFlagExpiry = 0xfd rdbFlagExpiry = 0xfd
@ -98,7 +98,7 @@ func (r *rdbReader) readObjectValue(t byte, l *Loader) ([]byte, error) {
switch t { switch t {
default: default:
return nil, errors.Errorf("unknown object-type %02x", t) return nil, errors.Errorf("unknown object-type %02x", t)
case rdbFlagAUX: case RdbFlagAUX:
fallthrough fallthrough
case rdbFlagResizeDB: case rdbFlagResizeDB:
fallthrough fallthrough

@ -679,6 +679,15 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) {
return return
} }
// load lua script
if e.Type == rdb.RdbFlagAUX && string(e.Key) == "lua" {
_, err := c.Do("script", "load", e.Value)
if err != nil {
log.Panicf(err.Error())
}
return
}
// TODO, need to judge big key // TODO, need to judge big key
if e.Type != rdb.RDBTypeStreamListPacks && if e.Type != rdb.RDBTypeStreamListPacks &&
(uint64(len(e.Value)) > conf.Options.BigKeyThreshold || e.RealMemberCount != 0) { (uint64(len(e.Value)) > conf.Options.BigKeyThreshold || e.RealMemberCount != 0) {

Loading…
Cancel
Save