Skip to content

Commit

Permalink
further tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
gregns1 committed Aug 7, 2024
1 parent d94ab9e commit 991922d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions db/revision_cache_lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ func (rc *LRURevisionCache) GetActive(ctx context.Context, docID string, collect

if !statEvent && err == nil {
// cache miss so we had to load doc, increment memory count
//docRev.CalculateBytes()
rc.memoryBytes.Add(docRev.MemoryBytes)
// check for rev cache memory based eviction
rc.revCacheMemoryBasedEviction()
Expand Down Expand Up @@ -502,7 +501,7 @@ func (delta *RevisionDelta) CalculateDeltaBytes() {
delta.totalDeltaBytes = int64(totalBytes)
}

// revCacheMemoryBasedEviction checks for rev cache eviction but first acquiring rev cache lock
// revCacheMemoryBasedEviction checks for rev cache eviction, if required calls performEviction which will acquire lock to evict
func (rc *LRURevisionCache) revCacheMemoryBasedEviction() {
// if memory capacity is not set, don't check for eviction this way
if rc.memoryCapacity > 0 && rc.memoryBytes.Value() > rc.memoryCapacity {
Expand Down
21 changes: 7 additions & 14 deletions db/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,15 @@ func TestParseRevisionsToAncestor(t *testing.T) {
revisions := Revisions{RevisionsStart: 5, RevisionsIds: []string{"five", "four", "three", "two", "one"}}
var revs []string

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (macos)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (windows)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / lint

revs declared and not used (typecheck)

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-default-collection

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-no-xattrs

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-race

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / lint

revs declared and not used (typecheck)

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (macos)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-default-collection

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-no-xattrs

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (windows)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu)

revs declared and not used

Check failure on line 87 in db/revision_test.go

View workflow job for this annotation

GitHub Actions / test-race

revs declared and not used

revs = revisions.parseAncestorRevisions("3-three")
assert.Equal(t, []string{"4-four", "3-three"}, revs)
revs = revisions.parseAncestorRevisions("4-four")
assert.Equal(t, []string{"4-four"}, revs)
revs = revisions.parseAncestorRevisions("1-one")
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revs)
revs = revisions.parseAncestorRevisions("5-five")
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revs)
revs = revisions.parseAncestorRevisions("0-zero")
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revs)
revs = revisions.parseAncestorRevisions("3-threeve")
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revs)
assert.Equal(t, []string{"4-four", "3-three"}, revisions.parseAncestorRevisions("3-three"))
assert.Equal(t, []string{"4-four"}, revisions.parseAncestorRevisions("4-four"))
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revisions.parseAncestorRevisions("1-one"))
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revisions.parseAncestorRevisions("5-five"))
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revisions.parseAncestorRevisions("0-zero"))
assert.Equal(t, []string{"4-four", "3-three", "2-two", "1-one"}, revisions.parseAncestorRevisions("3-threeve"))

shortRevisions := Revisions{RevisionsStart: 3, RevisionsIds: []string{"three"}}
revs = shortRevisions.parseAncestorRevisions("2-two")
assert.Equal(t, []string(nil), revs)
assert.Equal(t, []string(nil), shortRevisions.parseAncestorRevisions("2-two"))
}

// TestBackupOldRevision ensures that old revisions are kept around temporarily for in-flight requests and delta sync purposes.
Expand Down

0 comments on commit 991922d

Please sign in to comment.