| 423 | |
| 424 | template <class C> |
| 425 | RefCountCache<C>::RefCountCache(unsigned int num_partitions, int size, int items, ts::VersionNumber object_version, |
| 426 | const std::string &metrics_prefix) |
| 427 | : header(RefCountCacheHeader(object_version)) |
| 428 | { |
| 429 | this->max_size = size; |
| 430 | this->max_items = items; |
| 431 | this->num_partitions = num_partitions; |
| 432 | |
| 433 | this->rsb.refcountcache_current_items = Metrics::Gauge::createPtr((metrics_prefix + "current_items").c_str()); |
| 434 | this->rsb.refcountcache_current_size = Metrics::Gauge::createPtr((metrics_prefix + "current_size").c_str()); |
| 435 | this->rsb.refcountcache_total_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_inserts").c_str()); |
| 436 | this->rsb.refcountcache_total_failed_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_failed_inserts").c_str()); |
| 437 | this->rsb.refcountcache_total_lookups = Metrics::Counter::createPtr((metrics_prefix + "total_lookups").c_str()); |
| 438 | this->rsb.refcountcache_total_hits = Metrics::Counter::createPtr((metrics_prefix + "total_hits").c_str()); |
| 439 | this->rsb.refcountcache_last_sync_time = Metrics::Counter::createPtr((metrics_prefix + "last_sync.time").c_str()); |
| 440 | this->rsb.refcountcache_last_total_items = Metrics::Counter::createPtr((metrics_prefix + "last_sync.total_items").c_str()); |
| 441 | this->rsb.refcountcache_last_total_size = Metrics::Counter::createPtr((metrics_prefix + "last_sync.total_size").c_str()); |
| 442 | |
| 443 | // Now lets create all the partitions |
| 444 | this->partitions.reserve(num_partitions); |
| 445 | for (unsigned int i = 0; i < num_partitions; i++) { |
| 446 | this->partitions.push_back(new RefCountCachePartition<C>(i, size / num_partitions, items / num_partitions, &this->rsb)); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | // Deconstruct the class |
| 451 | template <class C> RefCountCache<C>::~RefCountCache() |
nothing calls this directly
no test coverage detected