acl/lib_dict/include/dict_pool.h

179 lines
6.0 KiB
C
Raw Normal View History

#ifndef __DICT_POOL_INCLUDE_H__
2014-11-19 00:25:21 +08:00
#define __DICT_POOL_INCLUDE_H__
#include "lib_acl.h"
#include "dict.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DICT_POOL DICT_POOL;
typedef struct DICT_POOL_DB DICT_POOL_DB;
/**
*
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_init(void);
/**
*
* @param partions {const char*}
* @param partions_size {int} partions
* @param dict_type {const char*} (btree/hash/cdb)
* @param dict_name {const char*}
* @param dict_size {int}
* @return {DICT_POOL*} , NULL
2014-11-19 00:25:21 +08:00
*/
DICT_API DICT_POOL *dict_pool_new(const char **partions, int partions_size,
const char *dict_type, const char *dict_path,
const char *dict_name, int pool_size);
/**
*
* @param pool {DICT_POOL*}
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_free(DICT_POOL *pool);
/**
* key/value
* @param pool {DICT_POOL*}
* @param key {char*}
* @param key_len {size_t} key
* @param value {char*}
* @param len {size_t} value ()
2014-11-19 00:25:21 +08:00
* @return {int} 0: OK, < 0: Error
*/
DICT_API int dict_pool_set(DICT_POOL *pool, char *key, size_t key_len, char *value, size_t len);
/**
*
* @param pool {DICT_POOL*}
* @param key {char*}
* @param key_len {size_t} key
* @param size {size_t*} ()
* @param {char*} ,
*
* acl_myfree/1
2014-11-19 00:25:21 +08:00
*/
DICT_API char *dict_pool_get(DICT_POOL *pool, char *key, size_t key_len, size_t *size);
/**
*
* @param pool {DICT_POOL*}
* @param key {char*}
* @param key_len {size_t} key
2014-11-19 00:25:21 +08:00
* @return {int} 0: ok; != 0: error
*/
DICT_API int dict_pool_del(DICT_POOL *pool, char *key, size_t key_len);
/**
*
* @param pool {DICT_POOL*}
* @param key {char**} ,
* key : acl_myfree/1,
* @param key_size {size_t*}
* @param val {char**} ,
* val : acl_myfree/1,
* @param val_size {size_t*}
* @return {int} 0: , != 0:
2014-11-19 00:25:21 +08:00
*/
DICT_API int dict_pool_seq(DICT_POOL *pool, char **key, size_t *key_size,
char **val, size_t *val_size);
/**
*
* @param pool {DICT_POOL*}
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_seq_reset(DICT_POOL *pool);
/**
*
* @param pool {DICT_POOL*}
* @return {int} 0: OK, != 0:
2014-11-19 00:25:21 +08:00
*/
DICT_API int dict_pool_seq_delcur(DICT_POOL *pool);
/**
* DB
* @param pool {DICT_POOL*}
* @param key {char*}
* @param key_len {size_t} key
* @return {DICT_POOL_DB*} DB
2014-11-19 00:25:21 +08:00
*/
DICT_API DICT_POOL_DB *dict_pool_db(DICT_POOL *pool, const char *key, size_t key_len);
/**
* DB的文件全路径
* @param pool {DICT_POOL*}
* @return {const char*}
2014-11-19 00:25:21 +08:00
*/
DICT_API const char *dict_pool_db_path(DICT_POOL_DB *db);
/**
* DB
* @param {DICT_POOL_DB*} DB
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_db_lock(DICT_POOL_DB *db);
/**
* DB
* @param {DICT_POOL_DB*} DB
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_db_unlock(DICT_POOL_DB *db);
/**
*
* @param {DICT_POOL_DB*} DB
* @param key {char*}
* @param key_len {size_t} key
* @param value {char*}
* @param len {size_t} value
2014-11-19 00:25:21 +08:00
* @return {int} 0: ok; < 0: error
*/
DICT_API int dict_pool_db_set(DICT_POOL_DB *db, char *key, size_t key_len, char *value, size_t len);
/**
* DB中获得某个健所对应的值
* @param {DICT_POOL_DB*} DB
* @param key {char*}
* @param key_len {size_t} key
* @param size {size_t*}
* @return {char*} , acl_myfree()/1
2014-11-19 00:25:21 +08:00
*/
DICT_API char *dict_pool_db_get(DICT_POOL_DB *db, char *key, size_t key_len, size_t *size);
/**
* DB中删除某个健对应的值
* @param {DICT_POOL_DB*} DB
* @param key {char*}
* @param key_len {size_t} key
2014-11-19 00:25:21 +08:00
* @return {int} 0: ok; != 0: error
*/
DICT_API int dict_pool_db_del(DICT_POOL_DB *db, char *key, size_t key_len);
/**
* DB
* @param {DICT_POOL_DB*} DB
2014-11-19 00:25:21 +08:00
*/
DICT_API void dict_pool_db_seq_reset(DICT_POOL_DB *db);
/**
* DB
* @param {DICT_POOL_DB*} DB
* @param key {char**}
* @param key_size {size_t*} key
* @param value {char**}
* @param value_size {size_t*} value
* @return {int} 0: , != 0:
2014-11-19 00:25:21 +08:00
*/
DICT_API int dict_pool_db_seq(DICT_POOL_DB *db, char **key, size_t *key_size,
char **val, size_t *val_size);
#ifdef __cplusplus
}
#endif
#endif