summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2020-02-25 18:09:05 -0800
committerdormando <dormando@rydia.net>2020-02-26 00:16:50 -0800
commit05721e4b6c393f25830021bb13f6637e5747dfcc (patch)
tree533ac96420a55842798070ee225a4ca32d39febc /cache.h
parent379e3df46dd2f08fb12f577bba70a9d7422b6f7c (diff)
downloadmemcached-05721e4b6c393f25830021bb13f6637e5747dfcc.tar.gz
add separate limits for connection buffers
allows specifying a megabyte limit for either response objects or read buffers. this is split among all of the worker threads. useful if connection limit is extremely high and you want to aggressively close connections if something happens and all connections become active at the same time. missing runtime tuning.
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/cache.h b/cache.h
index 16fc0a7..43267e8 100644
--- a/cache.h
+++ b/cache.h
@@ -3,18 +3,6 @@
#define CACHE_H
#include <pthread.h>
-#ifdef HAVE_UMEM_H
-#include <umem.h>
-#define cache_t umem_cache_t
-#define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
-#define do_cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
-#define cache_free(a, b) umem_cache_free(a, b)
-#define do_cache_free(a, b) umem_cache_free(a, b)
-#define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)
-#define cache_destroy(a) umem_cache_destroy(a);
-
-#else
-
#ifndef NDEBUG
/* may be used for debug purposes */
extern int cache_error;
@@ -59,6 +47,8 @@ typedef struct {
int total;
/** The current number of free elements */
int freecurr;
+ /** A limit on the total number of elements */
+ int limit;
/** The constructor to be called each time we allocate more memory */
cache_constructor_t* constructor;
/** The destructor to be called each time before we release memory */
@@ -116,6 +106,12 @@ void* do_cache_alloc(cache_t* handle);
*/
void cache_free(cache_t* handle, void* ptr);
void do_cache_free(cache_t* handle, void* ptr);
-#endif
+/**
+ * Set or adjust a limit for the number of objects to malloc
+ *
+ * @param handle handle to the object cache to adjust
+ * @param limit the number of objects to cache before returning NULL
+ */
+void cache_set_limit(cache_t* handle, int limit);
#endif