Skip to content
Snippets Groups Projects
Commit 766f188f authored by armatusmiles's avatar armatusmiles
Browse files

[+] dap_memcache_get func

parent 04f94d54
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,6 @@ ...@@ -4,13 +4,6 @@
static memcached_st *_memc; static memcached_st *_memc;
static time_t _expiration; 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) int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration)
{ {
_expiration = expiration; _expiration = expiration;
...@@ -41,13 +34,7 @@ int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration ...@@ -41,13 +34,7 @@ int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration
return 0; 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) bool dap_memcache_put(const char* key, void *value, size_t value_size)
{ {
memcached_return rc; memcached_return rc;
...@@ -59,6 +46,13 @@ bool dap_memcache_put(const char* key, void *value, size_t value_size) ...@@ -59,6 +46,13 @@ bool dap_memcache_put(const char* key, void *value, size_t value_size)
return true; 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 * @brief dap_memcached_deinit
*/ */
......
...@@ -16,6 +16,24 @@ ...@@ -16,6 +16,24 @@
* @return * @return
*/ */
int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration); int dap_memcached_init(const char *server_host, uint16_t port, time_t expiration);
/**
* @brief dap_memcached_deinit
*/
void dap_memcached_deinit(void); 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); 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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment