storage/cache/cache.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | template <typename Key> | ||
| 7 | class CachePolicy { | ||
| 8 | public: | ||
| 9 | 10 | virtual ~CachePolicy() = default; | |
| 10 | |||
| 11 | // Record key insertion into cache policy state. | ||
| 12 | virtual void OnInsert(const Key& key) = 0; | ||
| 13 | |||
| 14 | // Record key access (hit) into cache policy state. | ||
| 15 | virtual void OnAccess(const Key& key) = 0; | ||
| 16 | |||
| 17 | // Evict up to `count` keys and return them in eviction order. | ||
| 18 | virtual std::vector<Key> Evict(size_t count) = 0; | ||
| 19 | |||
| 20 | // Current tracked key count. | ||
| 21 | virtual size_t Size() const = 0; | ||
| 22 | }; | ||
| 23 |