func (s *RedisStore) Put(b *bucket.Bucket) error { defer s.Mchan.Time("bucket.put", time.Now()) rc := s.redisPool.Get() defer rc.Close() b.Lock() key, err := b.Id.Encode() value := b.Vals b.Unlock() if err != nil { return err } args := make([]interface{}, len(value)+1) args[0] = key for i := range value { x := strconv.FormatFloat(value[i], 'f', 10, 64) args[i+1] = []byte(x) } partition := s.bucketPartition(key) rc.Send("MULTI") rc.Send("RPUSH", args...) rc.Send("EXPIRE", key, 300) rc.Send("SADD", partition, key) rc.Send("EXPIRE", partition, 300) _, err = rc.Do("EXEC") if err != nil { return err } return nil }
func (s *RedisStore) Put(b *bucket.Bucket) error { defer utils.MeasureT("bucket.put", time.Now()) rc := s.redisPool.Get() defer rc.Close() b.Lock() key, err := b.Id.Encode() value := b.Vals b.Unlock() if err != nil { return err } //TODO(ryandotsmith): Ensure consistent keys are being written. partition := s.bucketPartition([]byte(key)) rc.Send("MULTI") rc.Send("RPUSH", key, value) rc.Send("EXPIRE", key, 300) rc.Send("SADD", partition, key) rc.Send("EXPIRE", partition, 300) _, err = rc.Do("EXEC") if err != nil { return err } return nil }