MXS-1992 Implement cache size control
The cache now enforces the defined maximum size by evicting some entries in case the insertion of a new entry would cause the max size to be exceeded. Currently the eviction algorithm simply removes a random element.
This commit is contained in:
@ -435,13 +435,25 @@ typedef struct query_classifier
|
||||
} QUERY_CLASSIFIER;
|
||||
|
||||
/**
|
||||
* QC_CACHE specifies the limits of the query classification cache.
|
||||
* QC_CACHE_PROPERTIES specifies the limits of the query classification cache.
|
||||
*/
|
||||
typedef struct QC_CACHE_PROPERTIES
|
||||
{
|
||||
int64_t max_size; /** The maximum size of the cache. */
|
||||
} QC_CACHE_PROPERTIES;
|
||||
|
||||
/**
|
||||
* QC_CACHE_STATS provides statistics of the cache.
|
||||
*/
|
||||
typedef struct QC_CACHE_STATS
|
||||
{
|
||||
int64_t size; /** The current size of the cache. */
|
||||
int64_t inserts; /** The number of inserts. */
|
||||
int64_t hits; /** The number of hits. */
|
||||
int64_t misses; /** The number of misses. */
|
||||
int64_t evictions; /** The number of evictions. */
|
||||
} QC_CACHE_STATS;
|
||||
|
||||
/**
|
||||
* Loads and sets up the default query classifier.
|
||||
*
|
||||
@ -850,4 +862,13 @@ void qc_set_server_version(uint64_t version);
|
||||
*/
|
||||
uint64_t qc_get_server_version();
|
||||
|
||||
/**
|
||||
* Get cache statistics for the calling thread.
|
||||
*
|
||||
* @param stats[out] Cache statistics.
|
||||
*
|
||||
* @return True, if caching is enabled, false otherwise.
|
||||
*/
|
||||
bool qc_get_cache_stats(QC_CACHE_STATS* stats);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
Reference in New Issue
Block a user