Skip to main content

HEXPIRE

Syntax

HEXPIRE key seconds [NX | XX | GT | LT] FIELDS numfields field [field...]

Module

hash

Categories

fast hash write

Description

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

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)