Esempio n. 1
0
// NewRegexpCache creates a new RegexpCache of the given size.
// The underlying cache internally uses a hash map, so lookups
// are cheap.
func NewRegexpCache(size int) *RegexpCache {
	return &RegexpCache{
		cache: cache.NewUnorderedCache(cache.Config{
			Policy: cache.CacheLRU,
			ShouldEvict: func(s int, key, value interface{}) bool {
				return s > size
			},
		}),
	}
}
Esempio n. 2
0
// newLeaseHolderCache creates a new leaseHolderCache of the given size.
// The underlying cache internally uses a hash map, so lookups
// are cheap.
func newLeaseHolderCache(size int) *leaseHolderCache {
	return &leaseHolderCache{
		cache: cache.NewUnorderedCache(cache.Config{
			Policy: cache.CacheLRU,
			ShouldEvict: func(s int, key, value interface{}) bool {
				return s > size
			},
		}),
	}
}
Esempio n. 3
0
func newState(m *MultiRaft) *state {
	return &state{
		MultiRaft: m,
		groups:    make(map[roachpb.RangeID]*group),
		nodes:     make(map[roachpb.NodeID]*node),
		writeTask: newWriteTask(m.Storage),
		replicaDescCache: cache.NewUnorderedCache(cache.Config{
			Policy: cache.CacheLRU,
			ShouldEvict: func(size int, key, value interface{}) bool {
				return size > maxReplicaDescCacheSize
			},
		}),
	}
}