feat(ttl): added ttl support in dump/restore
This commit is contained in:
parent
d68bc8979b
commit
98793b334a
2 changed files with 16 additions and 4 deletions
|
|
@ -81,6 +81,12 @@ func restore(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
writeEntry := badger.NewEntry([]byte(entry.Key), value).WithMeta(entryMeta)
|
||||
if entry.ExpiresAt != nil {
|
||||
if *entry.ExpiresAt < 0 {
|
||||
return fmt.Errorf("line %d: expires_at must be >= 0", lineNo)
|
||||
}
|
||||
writeEntry.ExpiresAt = uint64(*entry.ExpiresAt)
|
||||
}
|
||||
|
||||
if err := wb.SetEntry(writeEntry); err != nil {
|
||||
return fmt.Errorf("line %d: %w", lineNo, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue