HEXPIRE
Syntax
HEXPIRE key seconds [NX | XX | GT | LT] FIELDS numfields field [field...]
Module
hashCategories
fast hash writeDescription
Set an expiration (TTL or time to live) in seconds on one or more fields of a given hash key. You must specify at least one field. Field(s) will automatically be deleted from the hash key when their TTLs expire.
Examples
- Go (Embedded)
- CLI
Set the expiration in seconds for fields in the hash:
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
respArray, err := db.HExpire("key", 500, nil, field1, field2)
Set the expiration in seconds for fields in the hash:
> HEXPIRE key 500 FIELDS 2 field1 field2