summaryrefslogtreecommitdiff
path: root/src/mod_cml_funcs.c
diff options
context:
space:
mode:
authorJan Kneschke <jan@kneschke.de>2005-07-09 20:17:07 +0000
committerJan Kneschke <jan@kneschke.de>2005-07-09 20:17:07 +0000
commita03091d79e8dad7882e6b351971d653a5c61751a (patch)
treec64c1e399166dd13d2b88e0460df67af22a1d10a /src/mod_cml_funcs.c
parent673a6cd0a9c51970829305a450322c18b13957dd (diff)
downloadlighttpd-git-a03091d79e8dad7882e6b351971d653a5c61751a.tar.gz
added memcache support
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@432 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/mod_cml_funcs.c')
-rw-r--r--src/mod_cml_funcs.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/src/mod_cml_funcs.c b/src/mod_cml_funcs.c
index 43db70d9..902fd5a6 100644
--- a/src/mod_cml_funcs.c
+++ b/src/mod_cml_funcs.c
@@ -61,8 +61,10 @@ CACHE_FUNC_PROTO(f_file_mtime) {
return 0;
}
+#ifdef HAVE_MEMCACHE_H
CACHE_FUNC_PROTO(f_memcache_exists) {
- UNUSED(srv);
+ char *r;
+
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
@@ -74,13 +76,24 @@ CACHE_FUNC_PROTO(f_memcache_exists) {
}
tnode_prepare_long(result);
- VAL_LONG(result) = 0;
+
+ if (NULL == (r = mc_aget(p->conf.mc,
+ CONST_BUF_LEN(p->params->ptr[0]->data.str)))) {
+
+ VAL_LONG(result) = 0;
+ return 0;
+ }
+
+ free(r);
+
+ VAL_LONG(result) = 1;
return 0;
}
-CACHE_FUNC_PROTO(f_memcache_get) {
- UNUSED(srv);
+CACHE_FUNC_PROTO(f_memcache_get_string) {
+ char *r;
+
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
@@ -90,8 +103,52 @@ CACHE_FUNC_PROTO(f_memcache_get) {
return -1;
}
+ log_error_write(srv, __FILE__, __LINE__, "sb",
+ "f_memcache_get: couldn't find:",
+ p->params->ptr[0]->data.str);
+
+ if (NULL == (r = mc_aget(p->conf.mc,
+ p->params->ptr[0]->data.str->ptr, p->params->ptr[0]->data.str->used - 1))) {
+ log_error_write(srv, __FILE__, __LINE__, "sb",
+ "f_memcache_get: couldn't find:",
+ p->params->ptr[0]->data.str);
+ return -1;
+ }
tnode_prepare_string(result);
- buffer_copy_string_buffer(VAL_STRING(result), p->params->ptr[0]->data.str);
+ buffer_copy_string(VAL_STRING(result), r);
+
+ free(r);
+
+ return 0;
+}
+
+CACHE_FUNC_PROTO(f_memcache_get_long) {
+ char *r;
+
+ UNUSED(con);
+
+ if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
+ log_error_write(srv, __FILE__, __LINE__, "sd",
+ "f_memcache_get: I need a string:",
+ p->params->ptr[0]->type);
+ return -1;
+ }
+
+
+
+ if (NULL == (r = mc_aget(p->conf.mc,
+ CONST_BUF_LEN(p->params->ptr[0]->data.str)))) {
+ log_error_write(srv, __FILE__, __LINE__, "sb",
+ "f_memcache_get: couldn't find:",
+ p->params->ptr[0]->data.str);
+ return -1;
+ }
+
+ tnode_prepare_long(result);
+ VAL_LONG(result) = strtol(r, NULL, 10);
+
+ free(r);
return 0;
}
+#endif