]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/kmemcached: missing documentation, doc cleanup
authorMarek Vavruša <marek.vavrusa@nic.cz>
Sun, 7 Jun 2015 20:48:46 +0000 (22:48 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Sun, 7 Jun 2015 20:55:09 +0000 (22:55 +0200)
doc/modules.rst
lib/cache.h
lib/generic/lru.h
modules/kmemcached/README.rst [new file with mode: 0644]

index 237751ead65f8d03ea57fb7bcbebdf5f96681d19..b906a671c4ea083694875360cc2d42a427a5313a 100644 (file)
@@ -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
index a5a26569174cbc1aace7a8aa1532b48ffcf01f6c..4ee0550ea14e21909273a42dc24dcabb320de055 100644 (file)
@@ -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);
index 9060a183b3e724ba2f1ef63d25b5017e19ca5994..d4125f7e8a1266575ab48e9f6a8c3a3a666a6666 100644 (file)
@@ -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 (file)
index 0000000..71c88b8
--- /dev/null
@@ -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