From 4e500dea9790b5ff9ea4fbb3d150c358e3bd2cab Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 26 Feb 2014 15:02:50 +0100 Subject: [PATCH] Jumbo patch: Incorporate extraArgs in memcached key YAZ-747 Use plain text for things < 40 chars; SHA-1 for others. Except query and password. --- src/zoom-memcached.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/zoom-memcached.c b/src/zoom-memcached.c index cbf4a9a..70d7f3a 100644 --- a/src/zoom-memcached.c +++ b/src/zoom-memcached.c @@ -122,19 +122,37 @@ int ZOOM_memcached_configure(ZOOM_connection c) return 0; } +#if HAVE_LIBMEMCACHED_MEMCACHED_H +static void wrbuf_vary_puts(WRBUF w, const char *v) +{ + if (v) + { + if (strlen(v) > 40) + { + wrbuf_sha1_puts(w, v, 1); + } + else + { + wrbuf_puts(w, v); + } + } +} +#endif + void ZOOM_memcached_resultset(ZOOM_resultset r, ZOOM_query q) { #if HAVE_LIBMEMCACHED_MEMCACHED_H ZOOM_connection c = r->connection; + r->mc_key = wrbuf_alloc(); - wrbuf_puts(r->mc_key, "0;"); - wrbuf_puts(r->mc_key, c->host_port); + wrbuf_puts(r->mc_key, "1;"); + wrbuf_vary_puts(r->mc_key, c->host_port); + wrbuf_puts(r->mc_key, ";"); + wrbuf_vary_puts(r->mc_key, ZOOM_resultset_option_get(r, "extraArgs")); wrbuf_puts(r->mc_key, ";"); - if (c->user) - wrbuf_puts(r->mc_key, c->user); + wrbuf_vary_puts(r->mc_key, c->user); wrbuf_puts(r->mc_key, ";"); - if (c->group) - wrbuf_puts(r->mc_key, c->group); + wrbuf_vary_puts(r->mc_key, c->group); wrbuf_puts(r->mc_key, ";"); if (c->password) wrbuf_sha1_puts(r->mc_key, c->password, 1); @@ -146,8 +164,7 @@ void ZOOM_memcached_resultset(ZOOM_resultset r, ZOOM_query q) wrbuf_destroy(w); } wrbuf_puts(r->mc_key, ";"); - if (r->req_facets) - wrbuf_puts(r->mc_key, r->req_facets); + wrbuf_vary_puts(r->mc_key, r->req_facets); #endif } -- 1.7.10.4