Exemple #1
0
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))
}
Exemple #2
0
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))
}
Exemple #3
0
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))
}
Exemple #4
0
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)
}
Exemple #5
0
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)
}