Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set struct Item as the IsExpire() method's receiver #8

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ type Item struct {
}

// check expire cache
func IsExpire(t time.Time) bool {
return t.Before(time.Now().Local())
func (i Item) IsExpire() bool {
return i.Expire.Before(time.Now().Local())
}
4 changes: 2 additions & 2 deletions mcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (mc *CacheDriver) Get(key string, struc interface{}) bool {
return false
}
item := data.(entity.Item)
if entity.IsExpire(item.Expire) {
if item.IsExpire() {
return false
}
err := decodeBytes(item.Data, struc)
Expand All @@ -61,7 +61,7 @@ func (mc *CacheDriver) GetPointer(key string) (interface{}, bool) {
return entity.Item{}.DataLink, false
}
item := data.(entity.Item)
if entity.IsExpire(item.Expire) {
if item.IsExpire() {
return entity.Item{}.DataLink, false
}
return item.DataLink, true
Expand Down
2 changes: 1 addition & 1 deletion safeMap/safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func flush(s map[string]interface{}, keys []string) {
if !ok {
continue
}
if entity.IsExpire(value.(entity.Item).Expire) {
if value.(entity.Item).IsExpire() {
delete(s, v)
}
}
Expand Down