Belle II Software development
MetadataProvider::PayloadMetadataCache Class Reference

Simple caching structure to keep the payload information for this and the last exp/run. More...

#include <MetadataProvider.h>

Classes

struct  CacheEntry
 Each cache entry. More...
 

Public Member Functions

std::tuple< bool, PayloadMap * > get (int exp, int run)
 Get the list of map payloads from the cache This returns a tuple containing two elements:
 

Private Attributes

CacheEntry current
 currently valid conditions
 
CacheEntry previous
 previously valid conditions
 

Detailed Description

Simple caching structure to keep the payload information for this and the last exp/run.

This is mostly done to not request the payload information each time a new payload is created (during initialize) but also to make sure that flapping of run number doesn't excessively hammer the database. So we save the current and the last list of metadata

Definition at line 40 of file MetadataProvider.h.

Member Function Documentation

◆ get()

std::tuple< bool, PayloadMap * > get ( int  exp,
int  run 
)
inline

Get the list of map payloads from the cache This returns a tuple containing two elements:

  1. A bool whether the map was found in cache or whether a new empty map was returned.
  2. A pointer to the map either containing the payloads or where the payloads should be stored, always valid and owned by the cache.

Definition at line 55 of file MetadataProvider.h.

56 {
57 using std::get;
58 // if run mismatch swap current and last entry
59 if (current.exp != exp || current.run != run) std::swap(current, previous);
60 // still mismatch? if so clear, otherwise just return
61 const bool found = current.exp == exp and current.run == run;
62 if (!found) {
63 current.exp = exp;
64 current.run = run;
65 current.map.clear();
66 }
67 return {found, &current.map};
68 }
PayloadMap map
Map of all known name -> PayloadMetadata entries.

Member Data Documentation

◆ current

CacheEntry current
private

currently valid conditions

Definition at line 70 of file MetadataProvider.h.

◆ previous

CacheEntry previous
private

previously valid conditions

Definition at line 71 of file MetadataProvider.h.


The documentation for this class was generated from the following file: