// DUMP key func DumpCmd(s Session, args [][]byte) (redis.Resp, error) { if x, err := s.Store().Dump(s.DB(), args); err != nil { return toRespError(err) } else if dump, err := rdb.EncodeDump(x); err != nil { return toRespError(err) } else { return redis.NewBulkBytes(dump), nil } }
func (s *testStoreSuite) xrestore(c *C, db uint32, key string, ttlms uint64, value string) { var x rdb.String = []byte(value) dump, err := rdb.EncodeDump(x) c.Assert(err, IsNil) err = s.s.Restore(db, FormatBytes(key, ttlms, dump)) c.Assert(err, IsNil) s.xdump(c, db, key, value) if ttlms == 0 { s.kpttl(c, db, key, -1) } else { s.kpttl(c, db, key, int64(ttlms)) } }
func (s *testStoreSuite) xslotsrestore(c *C, db uint32, args ...interface{}) { x := []interface{}{} for i, a := range args { switch i % 3 { case 0, 1: x = append(x, a) case 2: dump, err := rdb.EncodeDump(rdb.String([]byte(a.(string)))) c.Assert(err, IsNil) x = append(x, dump) } } err := s.s.SlotsRestore(db, FormatBytes(x...)) c.Assert(err, IsNil) }
func (s *testStoreSuite) srestore(c *C, db uint32, key string, ttlms int64, expect ...string) { var x rdb.Set for _, e := range expect { x = append(x, []byte(e)) } dump, err := rdb.EncodeDump(x) c.Assert(err, IsNil) err = s.s.Restore(db, FormatBytes(key, ttlms, dump)) c.Assert(err, IsNil) s.sdump(c, db, key, expect...) if ttlms == 0 { s.kpttl(c, db, key, -1) } else { s.kpttl(c, db, key, int64(ttlms)) } }
func (s *testStoreSuite) hrestore(c *C, db uint32, key string, ttlms int64, expect ...string) { c.Assert(len(expect)%2, Equals, 0) var x rdb.Hash for i := 0; i < len(expect); i += 2 { x = append(x, &rdb.HashElement{Field: []byte(expect[i]), Value: []byte(expect[i+1])}) } dump, err := rdb.EncodeDump(x) c.Assert(err, IsNil) err = s.s.Restore(db, FormatBytes(key, ttlms, dump)) c.Assert(err, IsNil) s.hdump(c, db, key, expect...) if ttlms == 0 { s.kpttl(c, db, key, -1) } else { s.kpttl(c, db, key, int64(ttlms)) } }