MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / NewLRURevisionCache

Function NewLRURevisionCache

db/revision_cache_lru.go:143–157  ·  view source on GitHub ↗

Creates a revision cache with the given capacity and an optional loader function.

(revCacheOptions *RevisionCacheOptions, backingStores map[uint32]RevisionCacheBackingStore, cacheHitStat *base.SgwIntStat, cacheMissStat *base.SgwIntStat, cacheNumItemsStat *base.SgwIntStat, revCacheMemoryStat *base.SgwIntStat)

Source from the content-addressed store, hash-verified

141
142// Creates a revision cache with the given capacity and an optional loader function.
143func NewLRURevisionCache(revCacheOptions *RevisionCacheOptions, backingStores map[uint32]RevisionCacheBackingStore, cacheHitStat *base.SgwIntStat, cacheMissStat *base.SgwIntStat, cacheNumItemsStat *base.SgwIntStat, revCacheMemoryStat *base.SgwIntStat) *LRURevisionCache {
144
145 return &LRURevisionCache{
146 cache: map[IDAndRev]*list.Element{},
147 hlvCache: map[IDandCV]*list.Element{},
148 lruList: list.New(),
149 capacity: revCacheOptions.MaxItemCount,
150 backingStores: backingStores,
151 cacheHits: cacheHitStat,
152 cacheMisses: cacheMissStat,
153 cacheNumItems: cacheNumItemsStat,
154 cacheMemoryBytesStat: revCacheMemoryStat,
155 memoryCapacity: revCacheOptions.MaxBytes,
156 }
157}
158
159// Looks up a revision from the cache.
160// Returns the body of the revision, its history, and the set of channels it's in.

Calls

no outgoing calls