diff --git a/dap_memcached.c b/dap_memcached.c index c1364044848f6a63139c729765fa6d0cb592fa6c..2eeb9bf4b28661c6c1c2dd5f064ef0295672e6f7 100644 --- a/dap_memcached.c +++ b/dap_memcached.c @@ -4,13 +4,6 @@ static memcached_st *_memc; static time_t _expiration; -/** - * @brief dap_memcached_init - * @param server_host - * @param port - * @param expiration - * @return - */ int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration) { _expiration = expiration; @@ -41,13 +34,7 @@ int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration return 0; } -/** - * @brief dap_memcache_put - * @param key - * @param value - * @param value_size - * @return - */ + bool dap_memcache_put(const char* key, void *value, size_t value_size) { memcached_return rc; @@ -59,6 +46,13 @@ bool dap_memcache_put(const char* key, void *value, size_t value_size) return true; } +bool dap_memcache_get(const char* key, size_t * value_size, void ** result) +{ + memcached_return rc; + *result = memcached_get(_memc, key, strlen(key), value_size, NULL, &rc); + return rc == MEMCACHED_SUCCESS; +} + /** * @brief dap_memcached_deinit */ diff --git a/dap_memcached.h b/dap_memcached.h index d0c6b0c8fc1c2401d0b21101477e16d386b3f70f..607202ad30d8d4e832ae77863f99d303a957a174 100644 --- a/dap_memcached.h +++ b/dap_memcached.h @@ -16,6 +16,24 @@ * @return */ int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration); + +/** + * @brief dap_memcached_deinit + */ void dap_memcached_deinit(void); +/** + * @brief dap_memcache_put + * @param key + * @param value + * @param value_size + * @return + */ bool dap_memcache_put(const char* key, void *value, size_t value_size); + +/** + * @brief dap_memcache_get + * @param key + * @return true if key found + */ +bool dap_memcache_get(const char* key, size_t * value_size, void ** result);