Drizzled Public API Documentation

query_cache.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Toru Maesaka
00005  *  Copyright (C) 2010 Djellel Eddine Difallah
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; version 2 of the License.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <drizzled/plugin.h>
00024 #include <drizzled/plugin/plugin.h>
00025 #include <drizzled/sql_list.h>
00026 
00027 #include <drizzled/visibility.h>
00028 
00029 namespace drizzled
00030 {
00031 class Session;
00032 class select_result;
00033 
00034 namespace plugin
00035 {
00036 
00037 /* 
00038   This is the API that a qcache plugin must implement.
00039 */
00040 
00041 class DRIZZLED_API QueryCache : public Plugin
00042 {
00043 private:  
00044   
00045   QueryCache();
00046   QueryCache(const QueryCache &);
00047   QueryCache& operator=(const QueryCache &);
00048 
00049 public:  
00050 
00051   explicit QueryCache(std::string name_arg)
00052     : Plugin(name_arg, "QueryCache")
00053   {}
00054 
00055   virtual ~QueryCache() {}
00056 
00057   /* these are the Query Cache interface functions */
00058 
00059   /* Lookup the cache and transmit the data back to the client */
00060   virtual bool doIsCached(Session* session)= 0;  
00061   /* Lookup the cache and transmit the data back to the client */
00062   virtual bool doSendCachedResultset(Session *session)= 0;
00063   /* Send the current Resultset to the cache */
00064   virtual bool doSetResultset(Session *session)= 0;
00065   /* initiate a new Resultset (header) */
00066   virtual bool doPrepareResultset(Session *session)= 0;
00067   /* push a record to the current Resultset */
00068   virtual bool doInsertRecord(Session *session, List<Item> &item)= 0;
00069 
00070   static bool addPlugin(QueryCache *handler);
00071   static void removePlugin(QueryCache *handler);
00072 
00073   /* These are the functions called by the rest of the Drizzle server */
00074   static bool isCached(Session *session);
00075   static bool sendCachedResultset(Session *session);
00076   static bool prepareResultset(Session *session);
00077   static bool setResultset(Session *session);
00078   static bool insertRecord(Session *session, List<Item> &item);
00079 };
00080 
00081 } /* namespace plugin */
00082 } /* namespace drizzled */
00083