(ctx context.Context, docID, revID string, collectionID uint32, loadOnCacheMiss, includeDelta bool)
| 207 | } |
| 208 | |
| 209 | func (rc *LRURevisionCache) getFromCacheByRev(ctx context.Context, docID, revID string, collectionID uint32, loadOnCacheMiss, includeDelta bool) (DocumentRevision, error) { |
| 210 | value := rc.getValue(ctx, docID, revID, collectionID, loadOnCacheMiss) |
| 211 | if value == nil { |
| 212 | return DocumentRevision{}, nil |
| 213 | } |
| 214 | |
| 215 | // for revID pathway we should always load from backup if required |
| 216 | docRev, statEvent, err := value.load(ctx, rc.backingStores[collectionID], includeDelta, true) |
| 217 | rc.statsRecorderFunc(statEvent) |
| 218 | |
| 219 | if !statEvent && err == nil { |
| 220 | // cache miss so we had to load doc, increment memory count |
| 221 | rc.incrRevCacheMemoryUsage(ctx, value.getItemBytes()) |
| 222 | // check for memory based eviction |
| 223 | rc.revCacheMemoryBasedEviction(ctx) |
| 224 | // given err is nil if we get to this code we can safely assign error returned from addToHLVMapPostLoad to err |
| 225 | // and in the event we do error adding to the HLV map post load we will remove the value from the rev cache below |
| 226 | // and return the error to the caller |
| 227 | rc.addToHLVMapPostLoad(ctx, docID, docRev.RevID, docRev.CV, collectionID) |
| 228 | } |
| 229 | |
| 230 | if err != nil { |
| 231 | rc.removeValue(value, collectionID) // don't keep failed loads in the cache |
| 232 | } |
| 233 | |
| 234 | return docRev, err |
| 235 | } |
| 236 | |
| 237 | func (rc *LRURevisionCache) getFromCacheByCV(ctx context.Context, docID string, cv *Version, collectionID uint32, loadCacheOnMiss bool, includeDelta bool, loadBackup bool) (DocumentRevision, error) { |
| 238 | value := rc.getValueByCV(ctx, docID, cv, collectionID, loadCacheOnMiss) |
no test coverage detected