~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/qcache.h

  • Committer: Monty Taylor
  • Date: 2009-04-25 20:29:54 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090425202954-slopmkjj7vxal5lk
Migrated archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/*
 
2
 -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
3
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Toru Maesaka
5
 
 *  Copyright (C) 2010 Djellel Eddine Difallah
 
4
 
 
5
 *  Definitions required for Query Cache plugin
 
6
 
 
7
 *  Copyright (C) 2008 Mark Atwood, Toru Maesaka
6
8
 *
7
9
 *  This program is free software; you can redistribute it and/or modify
8
10
 *  it under the terms of the GNU General Public License as published by
21
23
#ifndef DRIZZLED_PLUGIN_QUERY_CACHE_H
22
24
#define DRIZZLED_PLUGIN_QUERY_CACHE_H
23
25
 
24
 
#include "drizzled/plugin.h"
25
 
#include "drizzled/plugin/plugin.h"
26
 
#include <drizzled/sql_list.h>
27
 
 
28
 
namespace drizzled
29
 
{
30
 
class Session;
31
 
class select_result;
32
 
 
33
 
namespace plugin
34
 
{
35
 
 
36
26
/* 
37
27
  This is the API that a qcache plugin must implement.
 
28
  it should implement each of these function pointers.
 
29
  if a function pointer is NULL (not loaded), that's ok.
 
30
 
 
31
  Return:
 
32
    false = success
 
33
    true  = failure
38
34
*/
39
 
 
40
 
class QueryCache : public Plugin
 
35
class QueryCache
41
36
{
42
 
private:  
43
 
  
44
 
  QueryCache();
45
 
  QueryCache(const QueryCache &);
46
 
  QueryCache& operator=(const QueryCache &);
47
 
 
48
 
public:  
49
 
 
50
 
  explicit QueryCache(std::string name_arg)
51
 
    : Plugin(name_arg, "QueryCache")
52
 
  {}
 
37
  std::string name;
 
38
public:
 
39
  QueryCache(std::string name_arg): name(name_arg) {}
 
40
  QueryCache(const char *name_arg): name(name_arg) {}
 
41
 
 
42
  std::string getName() { return name; }
53
43
 
54
44
  virtual ~QueryCache() {}
55
 
 
56
 
  /* these are the Query Cache interface functions */
57
 
 
58
 
  /* Lookup the cache and transmit the data back to the client */
59
 
  virtual bool doIsCached(Session* session)= 0;  
60
 
  /* Lookup the cache and transmit the data back to the client */
61
 
  virtual bool doSendCachedResultset(Session *session)= 0;
62
 
  /* Send the current Resultset to the cache */
63
 
  virtual bool doSetResultset(Session *session)= 0;
64
 
  /* initiate a new Resultset (header) */
65
 
  virtual bool doPrepareResultset(Session *session)= 0;
66
 
  /* push a record to the current Resultset */
67
 
  virtual bool doInsertRecord(Session *session, List<Item> &item)= 0;
68
 
 
69
 
  static bool addPlugin(QueryCache *handler);
70
 
  static void removePlugin(QueryCache *handler);
71
 
 
72
 
  /* These are the functions called by the rest of the Drizzle server */
73
 
  static bool isCached(Session *session);
74
 
  static bool sendCachedResultset(Session *session);
75
 
  static bool prepareResultset(Session *session);
76
 
  static bool setResultset(Session *session);
77
 
  static bool insertRecord(Session *session, List<Item> &item);
 
45
  /* Lookup the cache and transmit the data back to the client */
 
46
  virtual bool try_fetch_and_send(Session *session,
 
47
                                  bool is_transactional)= 0;
 
48
 
 
49
  virtual bool set(Session *session, bool is_transactional)= 0;
 
50
  virtual bool invalidate_table(Session *session, bool is_transactional)= 0;
 
51
  virtual bool invalidate_db(Session *session, const char *db_name,
 
52
                             bool transactional)= 0;
 
53
  virtual bool flush(Session *session)= 0;
78
54
};
79
55
 
80
 
} /* namespace plugin */
81
 
} /* namespace drizzled */
82
 
 
83
56
#endif /* DRIZZLED_PLUGIN_QUERY_CACHE_H */