示例#1
0
文件: migrate.go 项目: eswdd/bosun
func (db *DB) SDump(key []byte) ([]byte, error) {
	v, err := db.SMembers(key)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	return rdb.Dump(rdb.Set(v))
}
示例#2
0
文件: migrate.go 项目: eswdd/bosun
func (db *DB) LDump(key []byte) ([]byte, error) {
	v, err := db.LRange(key, 0, -1)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	return rdb.Dump(rdb.List(v))
}
示例#3
0
文件: migrate.go 项目: eswdd/bosun
func (db *DB) Dump(key []byte) ([]byte, error) {
	v, err := db.Get(key)
	if err != nil {
		return nil, err
	} else if v == nil {
		return nil, err
	}

	return rdb.Dump(rdb.String(v))
}
示例#4
0
文件: migrate.go 项目: eswdd/bosun
func (db *DB) ZDump(key []byte) ([]byte, error) {
	v, err := db.ZRangeByScore(key, MinScore, MaxScore, 0, -1)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	o := make(rdb.ZSet, len(v))
	for i := 0; i < len(v); i++ {
		o[i].Member = v[i].Member
		o[i].Score = float64(v[i].Score)
	}

	return rdb.Dump(o)
}
示例#5
0
文件: migrate.go 项目: eswdd/bosun
func (db *DB) HDump(key []byte) ([]byte, error) {
	v, err := db.HGetAll(key)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	o := make(rdb.Hash, len(v))
	for i := 0; i < len(v); i++ {
		o[i].Field = v[i].Field
		o[i].Value = v[i].Value
	}

	return rdb.Dump(o)
}