18 void extend (
int seconds = 600)
const;
32 class ThingiePool :
protected std::unordered_map<std::string, ThingieCache> {
34 using map_type = std::unordered_map<std::string, ThingieCache>;
78 time_t now = time (
nullptr);
Track data filter.
Definition: filter.h:38
Base class for songs, albums, artists, playlists, genres, etc.
Definition: musictypes.h:77
Type
Definition: musictypes.h:86
Generic data type.
Definition: parsnip.h:81
A ThingiePool that can persist & restore its data.
Definition: musiccache.h:67
void add(const ThingieList &things)
Definition: musiccache.h:119
PersistentPool(Media::Source *const src)
Initialize the cache/pool.
Definition: musiccache.cpp:207
bool isDirty() const
Check if the pool's data has been modified.
Definition: musiccache.h:87
void add(MusicThingie *thing)
Definition: musiccache.h:111
void add(const SongList &songs)
Definition: musiccache.h:115
void markDirty()
Mark data for persistence.
Definition: musiccache.h:77
Media::Source *const source
The source to which records will belong.
Definition: musiccache.h:69
virtual MusicThingie * reconstruct(MusicThingie::Type type, const Parsnip::Data &data)=0
Reconstructs a cached record.
time_t write_time
The time at which cached data should be saved.
Definition: musiccache.h:70
void restore(const Parsnip::Data &data)
Restore cache contents from serialized data.
Definition: musiccache.cpp:267
void clearDirty() const
Reset the pool-modified flag.
Definition: musiccache.h:92
bool writeIsDue() const
Check if the pool is due to be persisted.
Definition: musiccache.h:97
Parsnip::Data persist() const
Assemble the contents of the pool for serialization.
Definition: musiccache.cpp:220
A container for holding songs.
Definition: retainedlist.h:328
Base class for storing lists of thingies, which need to be reference counted accurately.
Definition: retainedlist.h:20
A cache/pool that retains all music thingies, mixed, and allows them to be retrieved from a single pl...
Definition: musiccache.h:32
void update(MusicThingie *thing)
Definition: musiccache.h:48
time_t next_purge
Definition: musiccache.h:36
time_t oldest_entry
Definition: musiccache.h:37
MusicThingie * get(const std::string &id)
Get an item from the cache.
Definition: musiccache.cpp:126
ThingiePoolParameters settings
Definition: musiccache.h:35
void erase(MusicThingie *thing)
Remove a thing from the cache.
Definition: musiccache.cpp:153
void purge(void)
Pare down the cache.
Definition: musiccache.cpp:161
std::unordered_map< std::string, ThingieCache > map_type
Definition: musiccache.h:34
ThingiePool()
Initialize a thingie storage cache/pool.
Definition: musiccache.cpp:34
void add(MusicThingie *thing, bool update=false)
Add (or update) an item to the cache.
Definition: musiccache.cpp:59
void periodic(void)
Periodically pare down the cache.
Definition: musiccache.h:57
void setParameters(const ThingiePoolParameters ¶ms)
Update the cache's retention parameters.
Definition: musiccache.cpp:46
Smart pointers for music thingie types.
Structure for tracking pool objects and their status for ThingiePool.
Definition: musiccache.h:15
time_t expiration
Definition: musiccache.h:17
Retainer< MusicThingie * > item
Definition: musiccache.h:16
void extend(int seconds=600) const
Extend the life of a cache object.
Definition: musiccache.cpp:27
Definition: musiccache.h:21
unsigned long size_type
Definition: musiccache.h:22
time_t purge_interval
Schedule periodic purges at this interval.
Definition: musiccache.h:27
size_type minimum_retained_items
Don't purge if we have less than this many.
Definition: musiccache.h:25
time_t reprieve_duration
Retain in-use objects at least this much longer.
Definition: musiccache.h:24
time_t initial_duration
Retain new or reinserted items for at least this amount of times.
Definition: musiccache.h:23
size_type maximum_retained_items
If we hit this many items, try purging before adding.
Definition: musiccache.h:26