Skip to content

Commit

Permalink
key can not be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
itmisx authored Jan 19, 2023
1 parent 0bed776 commit 140d804
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion string.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import (
)

// Set Key value with expiration and expiration callback function
func Set(key string, value interface{}, expiration time.Duration, expirationFunc func(key string, val interface{})) {
func Set(key string, value interface{}, expiration time.Duration, expirationFunc func(key string, value interface{})) (success bool) {
if key == "" {
return false
}
c.mu.Lock()
defer c.mu.Unlock()
c.items[key] = value
c.itemFunc[key] = expirationFunc
runJanitor(key, "", expiration)
return true
}

// Get the vlaue of given key , if exist return true, or return false
Expand Down

0 comments on commit 140d804

Please sign in to comment.