add-license-1
Basit Ali 2022-04-05 04:18:49 +05:00
parent 9242ee35fe
commit d0a7fc26e1
2 changed files with 4 additions and 4 deletions

4
set.go
View File

@ -1,10 +1,12 @@
package gocache
import "time"
func (cache *myCache) Set(key string, data interface{}) error {
cache.mutex.Lock()
defer cache.mutex.Unlock()
value := newValue(key, data, cache.expireAfter)
value := newValue(key, data, time.Now().UnixNano()+cache.expireAfter)
cache.items[key] = value
return nil

View File

@ -1,7 +1,5 @@
package gocache
import "time"
type value struct {
key string
data interface{}
@ -12,6 +10,6 @@ func newValue(key string, data interface{}, expiration int64) *value {
return &value{
key: key,
data: data,
expiration: time.Now().UnixNano() + expiration,
expiration: expiration,
}
}