RevisionCache is an interface that can be used to fetch a DocumentRevision for a Doc ID and Rev ID pair.
| 28 | |
| 29 | // RevisionCache is an interface that can be used to fetch a DocumentRevision for a Doc ID and Rev ID pair. |
| 30 | type RevisionCache interface { |
| 31 | |
| 32 | // GetWithRev returns the given revision, and stores if not already cached. |
| 33 | // When includeDelta=true, the returned DocumentRevision will include delta - requires additional locking during retrieval. |
| 34 | GetWithRev(ctx context.Context, docID, revID string, collectionID uint32, includeDelta bool) (DocumentRevision, error) |
| 35 | |
| 36 | // GetWithCV returns the given revision by CV, and stores if not already cached. |
| 37 | // When includeDelta=true, the returned DocumentRevision will include delta - requires additional locking during retrieval. |
| 38 | // When loadBackup=true, will load from backup revisions if requested version is not active document |
| 39 | GetWithCV(ctx context.Context, docID string, cv *Version, collectionID uint32, includeDelta bool, loadBackup bool) (DocumentRevision, error) |
| 40 | |
| 41 | // GetActive returns the current revision for the given doc ID, and stores if not already cached. |
| 42 | GetActive(ctx context.Context, docID string, collectionID uint32) (docRev DocumentRevision, err error) |
| 43 | |
| 44 | // Peek returns the given revision if present in the cache |
| 45 | Peek(ctx context.Context, docID, revID string, collectionID uint32) (docRev DocumentRevision, found bool) |
| 46 | |
| 47 | // Put will store the given docRev in the cache |
| 48 | Put(ctx context.Context, docRev DocumentRevision, collectionID uint32) |
| 49 | |
| 50 | // Upsert will remove existing value and re-create new one |
| 51 | Upsert(ctx context.Context, docRev DocumentRevision, collectionID uint32) |
| 52 | |
| 53 | // RemoveWithRev evicts a revision from the cache using its revID. |
| 54 | RemoveWithRev(ctx context.Context, docID, revID string, collectionID uint32) |
| 55 | |
| 56 | // RemoveWithCV evicts a revision from the cache using its current version. |
| 57 | RemoveWithCV(ctx context.Context, docID string, cv *Version, collectionID uint32) |
| 58 | |
| 59 | // RemoveRevOnly removes the specified key from the revID lookup map in the cache |
| 60 | RemoveRevOnly(ctx context.Context, docID, revID string, collectionID uint32) |
| 61 | |
| 62 | // RemoveCVOnly removes the specified key from the HLV lookup map in the cache |
| 63 | RemoveCVOnly(ctx context.Context, docID string, cv *Version, collectionID uint32) |
| 64 | |
| 65 | // UpdateDelta stores the given toDelta value in the given rev if cached |
| 66 | UpdateDelta(ctx context.Context, docID, revID string, collectionID uint32, toDelta RevisionDelta) |
| 67 | |
| 68 | // UpdateDeltaCV stores the given toDelta value in the given rev if cached but will look up in cache by cv |
| 69 | UpdateDeltaCV(ctx context.Context, docID string, cv *Version, collectionID uint32, toDelta RevisionDelta) |
| 70 | } |
| 71 | |
| 72 | const ( |
| 73 | RevCacheIncludeDelta = true |
no outgoing calls
no test coverage detected