NewExpireStructure returns a new ExpireStructure It will return a nil ExpireStructure if the database cannot be opened or the database cannot be created The database will be created if it does not exist
(options config.Options)
| 18 | // or the database cannot be created |
| 19 | // The database will be created if it does not exist |
| 20 | func NewExpireStructure(options config.Options) (*ExpireStructure, error) { |
| 21 | db, err := engine.NewDB(options) |
| 22 | if err != nil { |
| 23 | return nil, err |
| 24 | } |
| 25 | return &ExpireStructure{db: db}, nil |
| 26 | } |
| 27 | |
| 28 | func (ek *ExpireStructure) EXPIRE(key string, seconds int64) error { |
| 29 | deadtime := ek.getCurrentMiliUnixTimeStamp() + seconds*1000 |