drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
definition/cache.h
1/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2010 Brian Aker
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#pragma once
22
23#include <drizzled/table/instance.h>
24
25namespace drizzled {
26namespace definition {
27
28class Cache
29{
30public:
31 static size_t size()
32 {
33 // no lock?
34 return cache.size();
35 }
36
37 static void rehash(size_t arg)
38 {
39 // no lock?
40 cache.rehash(arg);
41 }
42
43 static table::instance::Shared::shared_ptr find(const identifier::Table::Key&);
44 static void erase(const identifier::Table::Key&);
45 static bool insert(const identifier::Table::Key&, table::instance::Shared::shared_ptr);
46private:
47 static void CopyFrom(table::instance::Shared::vector&);
48
49 typedef std::unordered_map< identifier::Table::Key, table::instance::Shared::shared_ptr> Map;
50
51 static Map cache;
52 static boost::mutex _mutex;
53
55};
56
57} /* namespace definition */
58} /* namespace drizzled */
59
TODO: Rename this file - func.h is stupid.