Exemple #1
0
// NewCacheMiddleware creates a new Cache middleware
func NewCacheMiddleware(maxItems int, ttl time.Duration) *CacheMiddleware {
	return &CacheMiddleware{
		cache: lru.New(maxItems),
		mutex: &sync.RWMutex{},
		ttl:   ttl,
	}
}
Exemple #2
0
func newMemoryCache(maxItems int) *memoryCache {
	return &memoryCache{
		Cache: lru.New(maxItems),
		mutex: &sync.Mutex{},
	}
}