setSetToDB
(key []byte, zSetValue *FSets, ttl time.Duration)
| 407 | |
| 408 | // setSetToDB |
| 409 | func (s *SetStructure) setSetToDB(key []byte, zSetValue *FSets, ttl time.Duration) error { |
| 410 | // create a new zSetValueWithTTL struct |
| 411 | var expire int64 = 0 |
| 412 | |
| 413 | if ttl != 0 { |
| 414 | expire = time.Now().Add(ttl).UnixNano() |
| 415 | } |
| 416 | |
| 417 | valueWithTTL := &FSetWithTTL{ |
| 418 | ZSet: zSetValue, |
| 419 | TTL: expire, |
| 420 | } |
| 421 | |
| 422 | val := encoding.NewMessagePackEncoder() |
| 423 | err := val.Encode(valueWithTTL) // Encode the value along with TTL |
| 424 | if err != nil { |
| 425 | return err |
| 426 | } |
| 427 | return s.db.Put(key, val.Bytes()) |
| 428 | } |
| 429 | |
| 430 | func (s *SetStructure) exists(key string, member ...string) bool { |
| 431 | if err := checkKey(key); err != nil { |