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.
31
#include <drizzled/message/resultset.pb.h>
32
#include <drizzled/sql_list.h>
36
class QueryCacheService
40
typedef std::map<std::string, drizzled::message::Resultset> CacheEntries;
41
typedef std::pair<const std::string, drizzled::message::Resultset> CacheEntry;
42
typedef std::map<std::string, std::vector<std::string>> CachedTablesEntries;
43
typedef std::pair<const std::string, std::vector<std::string>> CachedTablesEntry;
45
static const size_t DEFAULT_RECORD_SIZE= 100;
46
static CacheEntries cache;
47
static CachedTablesEntries cachedTables;
51
* Returns the singleton instance of QueryCacheService
53
static inline QueryCacheService &singleton()
55
static QueryCacheService query_cache_service;
56
return query_cache_service;
60
* Method which returns the active Resultset message
61
* for the supplied Session. If one is not found, a new Resultset
62
* message is allocated, initialized, and returned.
64
* @param The session processing the Select
66
drizzled::message::Resultset *setCurrentResultsetMessage(drizzled::Session *in_session);
69
* Helper method which initializes the header message for
72
* @param[inout] Resultset message container to modify
73
* @param[in] Pointer to the Session doing the processing
74
* @param[in] Pointer to the Table being inserted into
76
void setResultsetHeader(drizzled::message::Resultset &resultset,
77
drizzled::Session *in_session,
78
drizzled::TableList *in_table);
80
* Creates a new SelectRecord GPB message and pushes it to
83
* @param Pointer to the Session which has inserted a record
84
* @param Pointer to the List<Items> to add
86
bool addRecord(drizzled::Session *in_session, drizzled::List<drizzled::Item> &list);
89
static bool isCached(std::string query);
92
} /* namespace drizzled */