2
* Copyright (c) 2010, Djellel Eddine Difallah
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
8
* * Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* * Neither the name of Djellel Eddine Difallah nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
* THE POSSIBILITY OF SUCH DAMAGE.
29
#ifndef PLUGIN_MEMCACHED_QUERY_CACHE_QUERY_CACHE_SERVICE_H
30
#define PLUGIN_MEMCACHED_QUERY_CACHE_QUERY_CACHE_SERVICE_H
32
#include "drizzled/message/resultset.pb.h"
33
#include <drizzled/sql_list.h>
47
class QueryCacheService
51
typedef std::map<std::string, drizzled::message::Resultset> CacheEntries;
52
typedef std::pair<const std::string, drizzled::message::Resultset> CacheEntry;
53
typedef std::map<std::string, std::vector<std::string>> CachedTablesEntries;
54
typedef std::pair<const std::string, std::vector<std::string>> CachedTablesEntry;
56
static const size_t DEFAULT_RECORD_SIZE= 100;
57
static CacheEntries cache;
58
static CachedTablesEntries cachedTables;
62
* Returns the singleton instance of QueryCacheService
64
static inline QueryCacheService &singleton()
66
static QueryCacheService query_cache_service;
67
return query_cache_service;
71
* Method which returns the active Resultset message
72
* for the supplied Session. If one is not found, a new Resultset
73
* message is allocated, initialized, and returned.
75
* @param The session processing the Select
77
drizzled::message::Resultset *setCurrentResultsetMessage(drizzled::Session *in_session);
80
* Helper method which initializes the header message for
83
* @param[inout] Resultset message container to modify
84
* @param[in] Pointer to the Session doing the processing
85
* @param[in] Pointer to the Table being inserted into
87
void setResultsetHeader(drizzled::message::Resultset &resultset,
88
drizzled::Session *in_session,
89
drizzled::TableList *in_table);
91
* Creates a new SelectRecord GPB message and pushes it to
94
* @param Pointer to the Session which has inserted a record
95
* @param Pointer to the List<Items> to add
97
bool addRecord(drizzled::Session *in_session, drizzled::List<drizzled::Item> &list);
100
static bool isCached(std::string query);
103
} /* namespace drizzled */
104
#endif /* PLUGIN_MEMCACHED_QUERY_CACHE_QUERY_CACHE_SERVICE_H */