Example #1
0
File: lru.go Project: na--/nedomi
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
}
Example #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
}
Example #3
0
File: stats.go Project: na--/nedomi
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,
	}
}