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

Method GetVersionPruningWindow

db/database.go:1650–1682  ·  view source on GitHub ↗

GetVersionPruningWindow returns the current value for the XDCR Version Pruning Window for the backing bucket. if forceRefresh is set, we'll always fetch a new value from the bucket, even if we had one cached.

(ctx context.Context, forceRefresh bool)

Source from the content-addressed store, hash-verified

1648// GetVersionPruningWindow returns the current value for the XDCR Version Pruning Window for the backing bucket.
1649// if forceRefresh is set, we'll always fetch a new value from the bucket, even if we had one cached.
1650func (db *DatabaseContext) GetVersionPruningWindow(ctx context.Context, forceRefresh bool) time.Duration {
1651 // test override
1652 if db.Options.TestVersionPruningWindowOverride != nil {
1653 return *db.Options.TestVersionPruningWindowOverride
1654 }
1655
1656 // fetch cached value if available
1657 if !forceRefresh {
1658 vpw := db.CachedVersionPruningWindow.Load()
1659 if vpw != nil {
1660 return *vpw
1661 }
1662 }
1663
1664 // fetch from server
1665 cbStore, ok := base.AsCouchbaseBucketStore(db.Bucket)
1666 if !ok {
1667 return DefaultVersionPruningWindow
1668 }
1669
1670 serverVersionPruningWindow, err := cbStore.VersionPruningWindow(ctx)
1671 if err != nil {
1672 base.WarnfCtx(ctx, "Unable to retrieve server's version pruning window - using default %.2f days. %s", DefaultVersionPruningWindow.Hours()/24, err)
1673 }
1674
1675 vpw := DefaultVersionPruningWindow
1676 if serverVersionPruningWindow > 0 {
1677 vpw = serverVersionPruningWindow
1678 }
1679
1680 db.CachedVersionPruningWindow.Store(&vpw)
1681 return vpw
1682}
1683
1684// updateCCVSettings performs a management query to determine the latest crossClusterVersioning and max cas settings.
1685func (db *DatabaseContext) updateCCVSettings(ctx context.Context) error {

Callers 1

updateHLVMethod · 0.80

Calls 5

AsCouchbaseBucketStoreFunction · 0.92
WarnfCtxFunction · 0.92
LoadMethod · 0.80
StoreMethod · 0.80
VersionPruningWindowMethod · 0.65

Tested by

no test coverage detected