A simple TicTacToe app with Golang backend and WebSockets gluing it all together.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
830 B

package cache
import (
"sync"
"time"
uuid "github.com/satori/go.uuid"
)
// Item for caching
type Item struct {
Object interface{}
Expiration int64
}
// Cache is a simple in-memory cache for storing things
type Cache struct {
*cache
}
type cache struct {
defaultExpiration time.Duration
items map[uuid.UUID]Item
mu sync.RWMutex
onEvicted func(uuid.UUID, interface{})
janitor *janitor
}
const (
// NoExpiration For use with functions that take an expiration time.
NoExpiration time.Duration = -1
// DefaultExpiration For use with functions that take an expiration time.
// Equivalent to passing in the same expiration duration as was given to
// New() or NewFrom() when the cache was created (e.g. 5 minutes.)
DefaultExpiration time.Duration = time.Hour * 1
)