1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (c) 2009, Patrick "CaptTofu" Galbraith, Padraig O'Sullivan
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
10
* * Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright notice,
13
* this list of conditions and the following disclaimer in the documentation
14
* and/or other materials provided with the distribution.
15
* * Neither the name of Patrick Galbraith nor the names of its contributors
16
* may be used to endorse or promote products derived from this software
17
* without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29
* THE POSSIBILITY OF SUCH DAMAGE.
32
#include <drizzled/server_includes.h>
33
#include <drizzled/function/str/strfunc.h>
34
#include <drizzled/plugin/function.h>
36
#include "memcached_functions.h"
37
#include "memc_servers_set.h"
38
#include "memc_behavior_set.h"
39
#include "memc_behavior_get.h"
40
#include "memc_stats.h"
42
#include "memc_get_by_key.h"
44
#include "memc_set_by_key.h"
46
#include "memc_add_by_key.h"
47
#include "memc_replace.h"
48
#include "memc_replace_by_key.h"
49
#include "memc_delete.h"
50
#include "memc_delete_by_key.h"
51
#include "memc_append.h"
52
#include "memc_append_by_key.h"
53
#include "memc_prepend.h"
54
#include "memc_prepend_by_key.h"
56
#include "memc_cas_by_key.h"
57
#include "memc_increment.h"
58
#include "memc_decrement.h"
59
#include "memc_misc.h"
61
#include <libmemcached/memcached.h>
66
using namespace drizzled;
69
* A global memcached data structure needed by
70
* the various libmemcached API functions.
72
memcached_st *memc= NULL;
75
* The memcached UDF's.
77
plugin::Create_function<MemcachedServersSet> *memc_servers_set= NULL;
78
plugin::Create_function<MemcachedBehaviorSet> *memc_behavior_set= NULL;
79
plugin::Create_function<MemcachedBehaviorGet> *memc_behavior_get= NULL;
80
plugin::Create_function<MemcachedStats> *memc_stats= NULL;
81
plugin::Create_function<MemcachedGet> *memc_get= NULL;
82
plugin::Create_function<MemcachedGetByKey> *memc_get_by_key= NULL;
83
plugin::Create_function<MemcachedSet> *memc_set= NULL;
84
plugin::Create_function<MemcachedSetByKey> *memc_set_by_key= NULL;
85
plugin::Create_function<MemcachedAdd> *memc_add= NULL;
86
plugin::Create_function<MemcachedAddByKey> *memc_add_by_key= NULL;
87
plugin::Create_function<MemcachedReplace> *memc_replace= NULL;
88
plugin::Create_function<MemcachedReplaceByKey> *memc_replace_by_key= NULL;
89
plugin::Create_function<MemcachedIncrement> *memc_increment= NULL;
90
plugin::Create_function<MemcachedDecrement> *memc_decrement= NULL;
91
plugin::Create_function<MemcachedDelete> *memc_delete= NULL;
92
plugin::Create_function<MemcachedDeleteByKey> *memc_delete_by_key= NULL;
93
plugin::Create_function<MemcachedAppend> *memc_append= NULL;
94
plugin::Create_function<MemcachedAppendByKey> *memc_append_by_key= NULL;
95
plugin::Create_function<MemcachedPrepend> *memc_prepend= NULL;
96
plugin::Create_function<MemcachedPrependByKey> *memc_prepend_by_key= NULL;
97
plugin::Create_function<MemcachedCas> *memc_cas= NULL;
98
plugin::Create_function<MemcachedCasByKey> *memc_cas_by_key= NULL;
99
plugin::Create_function<MemcachedServerCount> *memc_serv_count= NULL;
100
plugin::Create_function<MemcachedVersion> *memc_version= NULL;
104
memc_servers_set= new plugin::Create_function<MemcachedServersSet>("memc_servers_set");
105
if (memc_servers_set == NULL)
110
memc_behavior_set= new plugin::Create_function<MemcachedBehaviorSet>("memc_behavior_set");
111
if (memc_behavior_set == NULL)
116
memc_behavior_get= new plugin::Create_function<MemcachedBehaviorGet>("memc_behavior_get");
117
if (memc_behavior_get == NULL)
122
memc_stats= new plugin::Create_function<MemcachedStats>("memc_stats");
123
if (memc_stats == NULL)
128
memc_get= new plugin::Create_function<MemcachedGet>("memc_get");
129
if (memc_get == NULL)
134
memc_get_by_key= new plugin::Create_function<MemcachedGetByKey>("memc_get_by_key");
135
if (memc_get_by_key == NULL)
140
memc_set= new plugin::Create_function<MemcachedSet>("memc_set");
141
if (memc_set == NULL)
145
memc_set_by_key= new plugin::Create_function<MemcachedSetByKey>("memc_set_by_key");
146
if (memc_set_by_key == NULL)
151
memc_add= new plugin::Create_function<MemcachedAdd>("memc_add");
157
memc_add_by_key= new plugin::Create_function<MemcachedAddByKey>("memc_add_by_key");
158
if (memc_add_by_key == NULL)
163
memc_replace= new plugin::Create_function<MemcachedReplace>("memc_replace");
164
if (memc_replace== NULL)
169
memc_replace_by_key= new plugin::Create_function<MemcachedReplaceByKey>("memc_replace_by_key");
170
if (memc_replace_by_key == NULL)
175
memc_delete= new plugin::Create_function<MemcachedDelete>("memc_delete");
176
if (memc_delete == NULL)
181
memc_delete_by_key= new plugin::Create_function<MemcachedDeleteByKey>("memc_delete_by_key");
182
if (memc_delete_by_key == NULL)
187
memc_append= new plugin::Create_function<MemcachedAppend>("memc_append");
188
if (memc_append == NULL)
193
memc_append_by_key= new plugin::Create_function<MemcachedAppendByKey>("memc_append_by_key");
194
if (memc_append_by_key == NULL)
199
memc_prepend= new plugin::Create_function<MemcachedPrepend>("memc_prepend");
200
if (memc_prepend == NULL)
205
memc_prepend_by_key= new plugin::Create_function<MemcachedPrependByKey>("memc_prepend_by_key");
206
if (memc_prepend_by_key == NULL)
211
memc_cas= new plugin::Create_function<MemcachedCas>("memc_cas");
212
if (memc_cas == NULL)
217
memc_cas_by_key= new plugin::Create_function<MemcachedCasByKey>("memc_cas_by_key");
218
if (memc_cas_by_key == NULL)
223
memc_serv_count= new plugin::Create_function<MemcachedServerCount>("memc_server_count");
224
if (memc_serv_count == NULL)
229
memc_version= new plugin::Create_function<MemcachedVersion>("memc_libmemcached_version");
230
if (memc_version == NULL)
235
memc_increment= new plugin::Create_function<MemcachedIncrement>("memc_increment");
236
if (memc_increment == NULL)
241
memc_decrement= new plugin::Create_function<MemcachedDecrement>("memc_decrement");
242
if (memc_decrement == NULL)
250
void cleanupMemcUDF()
252
delete memc_servers_set;
253
delete memc_behavior_set;
254
delete memc_behavior_get;
257
delete memc_get_by_key;
259
delete memc_set_by_key;
261
delete memc_add_by_key;
263
delete memc_replace_by_key;
265
delete memc_delete_by_key;
267
delete memc_append_by_key;
269
delete memc_prepend_by_key;
271
delete memc_cas_by_key;
272
delete memc_serv_count;
274
delete memc_increment;
275
delete memc_decrement;
278
static int memcachedInit(drizzled::plugin::Registry ®istry)
285
memc= memcached_create(NULL);
287
registry.add(memc_servers_set);
288
registry.add(memc_behavior_set);
289
registry.add(memc_behavior_get);
290
registry.add(memc_stats);
291
registry.add(memc_get);
292
registry.add(memc_get_by_key);
293
registry.add(memc_set);
294
registry.add(memc_set_by_key);
295
registry.add(memc_add);
296
registry.add(memc_add_by_key);
297
registry.add(memc_replace);
298
registry.add(memc_replace_by_key);
299
registry.add(memc_delete);
300
registry.add(memc_delete_by_key);
301
registry.add(memc_append);
302
registry.add(memc_append_by_key);
303
registry.add(memc_prepend);
304
registry.add(memc_prepend_by_key);
305
registry.add(memc_cas);
306
registry.add(memc_cas_by_key);
307
registry.add(memc_serv_count);
308
registry.add(memc_version);
309
registry.add(memc_increment);
310
registry.add(memc_decrement);
315
static int memcachedDone(drizzled::plugin::Registry ®istry)
318
memcached_free(memc);
320
registry.remove(memc_servers_set);
321
registry.remove(memc_behavior_set);
322
registry.remove(memc_behavior_get);
323
registry.remove(memc_stats);
324
registry.remove(memc_get);
325
registry.remove(memc_get_by_key);
326
registry.remove(memc_set);
327
registry.remove(memc_set_by_key);
328
registry.remove(memc_add);
329
registry.remove(memc_add_by_key);
330
registry.remove(memc_replace);
331
registry.remove(memc_replace_by_key);
332
registry.remove(memc_delete);
333
registry.remove(memc_delete_by_key);
334
registry.remove(memc_append);
335
registry.remove(memc_append_by_key);
336
registry.remove(memc_prepend);
337
registry.remove(memc_prepend_by_key);
338
registry.remove(memc_cas);
339
registry.remove(memc_cas_by_key);
340
registry.remove(memc_serv_count);
341
registry.remove(memc_version);
342
registry.remove(memc_increment);
343
registry.remove(memc_decrement);
350
drizzle_declare_plugin(memcached_functions)
352
"memcached_functions",
354
"Patrick Galbraith, Ronald Bradford, Padraig O'Sullivan",
355
"Memcached UDF Plugin",
363
drizzle_declare_plugin_end;