summaryrefslogtreecommitdiff
path: root/include/apr_memcache.h
diff options
context:
space:
mode:
authorpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2007-06-08 05:37:04 +0000
committerpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2007-06-08 05:37:04 +0000
commit98a074d12169b84051fab820cf7d576f09070e90 (patch)
tree9fb224fff8ec902dd41ed5d2f0e3a6b26ca2282d /include/apr_memcache.h
parent9198ee8006f9ecbd0efcdae84ac94821ec397c80 (diff)
downloadlibapr-util-98a074d12169b84051fab820cf7d576f09070e90.tar.gz
Make the hash calculation function used for server selection a plugable part of the API, allowing end users to use something other than our non-standard CRC.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@545425 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_memcache.h')
-rw-r--r--include/apr_memcache.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/apr_memcache.h b/include/apr_memcache.h
index 273a7b20..4f90a9a2 100644
--- a/include/apr_memcache.h
+++ b/include/apr_memcache.h
@@ -74,6 +74,15 @@ struct apr_memcache_server_t
apr_time_t btime;
};
+/* Custom hash callback function prototype, user for server selection.
+* @param baton user selected baton
+* @param data data to hash
+* @param data_len length of data
+*/
+typedef apr_uint32_t (*apr_memcahce_hash_func)(void *baton,
+ const char *data,
+ apr_size_t data_len);
+
/** Container for a set of memcached servers */
typedef struct
{
@@ -82,6 +91,8 @@ typedef struct
apr_uint16_t ntotal; /**< Number of Servers Added */
apr_memcache_server_t **live_servers; /**< Array of Servers */
apr_pool_t *p; /** Pool to use for allocations */
+ void *hash_baton;
+ apr_memcahce_hash_func hash_func;
} apr_memcache_t;
/** Returned Data from a multiple get */
@@ -101,7 +112,13 @@ typedef struct
* @return crc32 hash of data
* @remark The crc32 hash is not compatible with old memcached clients.
*/
-APR_DECLARE(apr_uint32_t) apr_memcache_hash(const char *data, apr_size_t data_len);
+APR_DECLARE(apr_uint32_t) apr_memcache_hash(apr_memcache_t *mc,
+ const char *data,
+ apr_size_t data_len);
+
+APR_DECLARE(apr_uint32_t) apr_memcache_hash_default(void *baton,
+ const char *data,
+ apr_size_t data_len);
/**
* Picks a server based on a hash