From: Marek VavrusÌŒa Date: Sun, 7 Jun 2015 20:48:46 +0000 (+0200) Subject: modules/kmemcached: missing documentation, doc cleanup X-Git-Tag: v1.0.0-beta1~120^2~20^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d6e2de43171d8da38e482ba53844719c72bc875;p=thirdparty%2Fknot-resolver.git modules/kmemcached: missing documentation, doc cleanup --- diff --git a/doc/modules.rst b/doc/modules.rst index 237751ead..b906a671c 100644 --- a/doc/modules.rst +++ b/doc/modules.rst @@ -14,3 +14,4 @@ Implemented modules .. include:: ../modules/cachectl/README.rst .. include:: ../modules/graphite/README.rst .. include:: ../modules/ketcd/README.rst +.. include:: ../modules/kmemcached/README.rst diff --git a/lib/cache.h b/lib/cache.h index a5a265691..4ee0550ea 100644 --- a/lib/cache.h +++ b/lib/cache.h @@ -64,9 +64,9 @@ struct kr_cache_txn { /** * Open/create cache with provided storage options. * @param cache cache structure to be initialized - * @param api Storage engine - * @param storage_opts Storage-specific options (may be NULL for default) - * @param mm Memory context. + * @param api storage engine API + * @param opts storage-specific options (may be NULL for default) + * @param mm memory context. * @return 0 or an error code */ int kr_cache_open(struct kr_cache *cache, const namedb_api_t *api, void *opts, mm_ctx_t *mm); diff --git a/lib/generic/lru.h b/lib/generic/lru.h index 9060a183b..d4125f7e8 100644 --- a/lib/generic/lru.h +++ b/lib/generic/lru.h @@ -97,7 +97,7 @@ struct lru_hash_base { char slots[]; }; -/** @breif User-defined hashtable. */ +/** @brief User-defined hashtable. */ #define lru_hash(type) \ struct { \ lru_hash_struct \ @@ -155,9 +155,9 @@ static inline void *lru_slot_set(struct lru_hash_base *lru, const char *key, uin * @param table hash table * @param max_slots number of slots */ -#define lru_init(table, max_size) \ - (memset((table), 0, sizeof(*table) + (max_size) * sizeof((table)->slots[0])), \ - (table)->stride = sizeof((table)->slots[0]), (table)->size = (max_size)) +#define lru_init(table, max_slots) \ + (memset((table), 0, sizeof(*table) + (max_slots) * sizeof((table)->slots[0])), \ + (table)->stride = sizeof((table)->slots[0]), (table)->size = (max_slots)) /** * @brief Free all keys and evict all values. diff --git a/modules/kmemcached/README.rst b/modules/kmemcached/README.rst new file mode 100644 index 000000000..71c88b8c6 --- /dev/null +++ b/modules/kmemcached/README.rst @@ -0,0 +1,42 @@ +Memcached cache storage +----------------------- + +Module providing a cache storage backend for memcached_, which makes a good fit for +making a shared cache between resolvers. + +After loading you can see the storage backend registered and useable. + +.. code-block:: lua + + > modules.load 'kmemcached' + > cache.backends() + [memcached://] => true + +And you can use it right away, see the `libmemcached configuration`_ reference for configuration string +options, the most essential ones are `--SERVER` or `--SOCKET`. Here's an example for connecting to UNIX socket. + +.. code-block:: lua + + > cache.storage = 'memcached://--SOCKET="/var/sock/memcached"' + +.. note:: The memcached_ instance **MUST** support binary protocol, in order to make it work with binary keys. You can pass other options to the configuration string for performance tuning. + +.. warning:: The memcached_ server is responsible for evicting entries out of cache, the pruning function is not implemented, and neither is aborting write transactions. + +Build resolver shared cache +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The memcached_ takes care of the data replication and fail over, you can add multiple servers at once. + +.. code-block:: lua + + > cache.storage = 'memcached://--SOCKET="/var/sock/memcached" --SERVER=192.168.1.1 --SERVER=cache2.domain' + +Dependencies +^^^^^^^^^^^^ + +Depends on the libmemcached_ library. + +.. _memcached: http://memcached.org/ +.. _libmemcached: http://libmemcached.org/libMemcached.html +.. _`libmemcached configuration`: http://docs.libmemcached.org/libmemcached_configuration.html#description