Exemple #1
0
func (tc *TieredLRUCache) consumedSize() types.BytesSize {
	var sum types.BytesSize

	for i := 0; i < cacheTiers; i++ {
		sum += (tc.cfg.PartSize * types.BytesSize(tc.tiers[i].Len()))
	}

	return sum
}
Exemple #2
0
func getTestDiskStorage(t *testing.T, partSize int) (*Disk, string, func()) {
	diskPath, cleanup := testutils.GetTestFolder(t)

	d, err := New(&config.CacheZone{
		Path:     diskPath,
		PartSize: types.BytesSize(partSize),
	}, mock.NewLogger())

	if err != nil {
		t.Fatalf("Could not create storage: %s", err)
	}

	return d, diskPath, cleanup
}
Exemple #3
0
func (tc *TieredLRUCache) stats() types.CacheStats {
	var sum types.BytesSize
	var allObjects uint64

	for i := 0; i < cacheTiers; i++ {
		objects := types.BytesSize(tc.tiers[i].Len())
		sum += (tc.cfg.PartSize * objects)
		allObjects += uint64(objects)
	}

	return &TieredCacheStats{
		id:       tc.cfg.Path,
		hits:     tc.hits,
		requests: tc.requests,
		size:     sum,
		objects:  allObjects,
	}
}