You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
proxysql/include/query_cache.h____

96 lines
2.2 KiB

#ifndef __CLASS_QUERY_CACHE_H
#define __CLASS_QUERY_CACHE_H
#include "proxysql.h"
#include "cpp.h"
/*
#define EXPIRE_DROPIT 0
#define SHARED_QUERY_CACHE_HASH_TABLES 16
#define HASH_EXPIRE_MAX 3600*24*365*10
#define DEFAULT_purge_loop_time 400000
#define DEFAULT_purge_total_time 10000000
#define DEFAULT_purge_threshold_pct_min 50
#define DEFAULT_purge_threshold_pct_max 90
*/
#define DEFAULT_SQC_size 64*1024*1024
/*
typedef struct __fdb_hash_t fdb_hash_t;
typedef struct __fdb_hash_entry fdb_hash_entry;
*/
/*
struct __fdb_hash_t {
pthread_rwlock_t lock;
GHashTable *hash;
GPtrArray *ptrArray;
uint64_t dataSize;
uint64_t purgeChunkSize;
uint64_t purgeIdx;
};
struct __fdb_hash_entry {
unsigned char *key;
unsigned char *value;
fdb_hash_t *hash;
struct __fdb_hash_entry *self;
uint32_t klen;
uint32_t length;
time_t expire;
time_t access;
uint32_t ref_count;
};
*/
class Query_Cache {
public:
virtual void * purgeHash_thread(void *);
//GPtrArray *LQCs; // array of Local Query Cache . These are used to update QCnow from the Shared_Query_Cache
int size;
int shutdown;
time_t QCnow;
pthread_t purge_thread_id;
//fdb_hash_t fdb_hashes[SHARED_QUERY_CACHE_HASH_TABLES];
unsigned int purge_loop_time;
unsigned int purge_total_time;
unsigned int purge_threshold_pct_min;
unsigned int purge_threshold_pct_max;
// unsigned int hash_expire_default;
uint64_t max_memory_size;
uint64_t cntDel;
uint64_t cntGet;
uint64_t cntGetOK;
uint64_t cntSet;
uint64_t cntSetERR;
uint64_t cntPurge;
uint64_t size_keys;
uint64_t size_values;
uint64_t size_metas;
uint64_t dataIN;
uint64_t dataOUT;
// Shared_Query_Cache();
Query_Cache(uint64_t _max_memory_size=DEFAULT_SQC_size);
~Query_Cache();
virtual bool set(unsigned char *, uint32_t, unsigned char *, uint32_t, time_t);
virtual unsigned char * get(const unsigned char *);
virtual uint64_t flush();
virtual uint64_t current_free_memory();
virtual unsigned int current_used_memory_pct();
// void register_LQC(Local_Query_Cache *);
// void unregister_LQC(Local_Query_Cache *);
};
// the types of the class factories
typedef Query_Cache* create_QueryCache();
typedef void destroy_QueryCache(Query_Cache*);
#endif /* __CLASS_QUERY_CACHE_H */