Hello App: cache.cpp
Contents
cache.cpp
/**
* cache.cpp - manage a cache of HelloApp data structures
*
* Copyright (c) 2024 HanoverSoft
* Written by Anthony V. Edwards
* 820 Churchill Drive, Chapel Hill, NC 27517
* ave@hanoversoft.net
*
* This file is the source (read-write) for these structures:
* HelloApp
*/
#include "hello.h"
#include <MAE.h>
// data structure caches
Cache<HelloApp> HelloCache;
// Used in mgmtHello.cpp, queryable by supervisor daemon
string CacheList= "User"; // the list of parameter categories
int HelloCache_max= User_CACHE_MAX; // the maximum size of the session cache
/** Allocate our cache of HelloApp instances.
* Specify how to manage the cache.
* @param appname - the app name to use when querying system properties (ignored)
* @return true upon success, false if any error encounted
*/
{
// initialize the cache sizes
HelloCache_max= User_CACHE_MAX; //Property::getValueInt(appname, "cache", "Hello", User_CACHE_MAX);
// specify how this cache should behave
HelloCache.setReadOnly() // Don't auto-save anything
.setFetchDirect() // If it did fetch anything, fetch it directly from the data store (don't call HelloApp::cache())
.setSize(HelloCache_max); // Set the maximum size of the cache (when size exceeded, old instances would be save()ed before deletion)
// success
return true;
}