regify utility  2.0.0-0
Key Value Storage

A generic storage interface. More...

Data Structures

struct  KvStore_
 The key/value store interface type. This object holds the kvget, kvlist and kvset methods of an implementation. More...
 

Typedefs

typedef int32_t(* kvset) (struct KvStore_ *kvs, const char *key, const char *val, rusize len)
 KvStore setter function interface. More...
 
typedef int32_t(* kvget) (struct KvStore_ *kvs, const char *key, char **val, rusize *len)
 KvStore getter function interface. More...
 
typedef int32_t(* kvlist) (struct KvStore_ *kvs, const char *key, ruList *list)
 KvStore list function interface. More...
 
typedef struct KvStore_ KvStore
 The key/value store interface type. This object holds the kvget, kvlist and kvset methods of an implementation. More...
 
typedef void * ruFileStore
 Opaque pointer to a File based KvStore interface. More...
 
typedef void * ruNullStore
 Opaque pointer to a Null KvStore interface. More...
 

Functions

RUAPI KvStoreruNewStore (void)
 Returns a generic KvStore interface. This function is mainly used by those implementing the KvStore interface. More...
 
RUAPI void ruFreeStore (void *obj)
 Public function to free the given KvStore object. More...
 
RUAPI int32_t ruValidStore (void *obj)
 Checks given object to be a valid KvStore object. More...
 
RUAPI KvStoreruNewFileStore (const char *folderPath, int32_t *code)
 Returns a newly created file system based KvStore object. If there is already store data in the given folder, it is opened and used. More...
 
RUAPI int32_t ruFileStoreSet (KvStore *kvs, const char *key, const char *val, rusize len)
 Set the value of key in the given FileStore. More...
 
RUAPI int32_t ruFileStoreGet (KvStore *kvs, const char *key, char **val, rusize *len)
 Get the value of key from the given FileStore. More...
 
RUAPI int32_t ruFileStoreList (KvStore *kvs, const char *key, ruList *result)
 Returns a list of keys under the given key. More...
 
RUAPI KvStoreruNewNullStore (void)
 Returns a newly created NULL based KvStore interface. This keystore silently ignores setters and never returns data. More...
 
RUAPI int32_t ruNullStoreSet (KvStore *kvs, const char *key, const char *val, rusize len)
 Set the value of key in the given FileStore. More...
 
RUAPI int32_t ruNullStoreGet (KvStore *kvs, const char *key, char **val, rusize *len)
 Get the value of key from the given KvStore. More...
 
RUAPI int32_t ruNullStoreList (KvStore *kvs, const char *key, ruList *list)
 Returns a list of items under given key. More...
 

Detailed Description

A generic storage interface.

Key Value Storage

Currently provided implementations are ruFileStore for file system based storage and ruNullStore to omit local storage altogether. It consists of a simple kvget, kvset and kvlist call.

Key Value Storage

A Key Value Store is a generic storage interface designed to allow for flexible data serialization.

kvstore key

This is a space separated string that also accept filesystem type globs like *. Each intersecting space indicates a sub level much like a folder in a file system, or a sub branch in a hierarchy. In most cases * is only supported at the end.

Typedef Documentation

◆ kvget

typedef int32_t(* kvget) (struct KvStore_ *kvs, const char *key, char **val, rusize *len)

KvStore getter function interface.

Parameters
kvsKvStore object.
keyThe kvstore key to the data in question.
valWhere the retrieved value will be stored. Most of the time the caller should free this with ruFree when done with it. See implementation details.
lenThe number of bytes that make up val.
Returns
RUE_OK on success else an error code.

◆ kvlist

typedef int32_t(* kvlist) (struct KvStore_ *kvs, const char *key, ruList *list)

KvStore list function interface.

Parameters
kvsKvStore context where data will be retrieved from.
keyThe kvstore key to the data in question. Should end with a *.
listAn ruList of kvstore key strings. Should be freed with ruListFree after use.
Returns
RUE_OK on success else an error code.

◆ kvset

typedef int32_t(* kvset) (struct KvStore_ *kvs, const char *key, const char *val, rusize len)

KvStore setter function interface.

Parameters
kvsKvStore object.
keyThe kvstore key to the data in question.
valThe value that will be stored or NULL if the key is to be removed.
lenThe number of bytes that make up val or RU_SIZE_AUTO.
Returns
RUE_OK on success else an error code.

◆ KvStore

typedef struct KvStore_ KvStore

The key/value store interface type. This object holds the kvget, kvlist and kvset methods of an implementation.

◆ ruFileStore

typedef void* ruFileStore

Opaque pointer to a File based KvStore interface.

◆ ruNullStore

typedef void* ruNullStore

Opaque pointer to a Null KvStore interface.

Function Documentation

◆ ruFileStoreGet()

RUAPI int32_t ruFileStoreGet ( KvStore kvs,
const char *  key,
char **  val,
rusize len 
)

Get the value of key from the given FileStore.

Parameters
kvsFileStore context where data will be retrieved from.
keyThe kvstore key to the data in question.
valWhere the retrieved value will be stored. Caller should free this with ruFree when done with it.
lenThe number of bytes that make up val.
Returns
RUE_OK on success else an error code.

◆ ruFileStoreList()

RUAPI int32_t ruFileStoreList ( KvStore kvs,
const char *  key,
ruList result 
)

Returns a list of keys under the given key.

Parameters
kvsFileStore context where key will be listed from.
keyThe kvstore key to the data in question. May end with " *"
resultAn ruList of kvstore key strings. Should be freed with ruListFree after use.
Returns
RUE_OK on success else an error code.

◆ ruFileStoreSet()

RUAPI int32_t ruFileStoreSet ( KvStore kvs,
const char *  key,
const char *  val,
rusize  len 
)

Set the value of key in the given FileStore.

Parameters
kvsFileStore context where data will be stored.
keyThe kvstore key to the data in question.
valThe value that will be stored or NULL if the key is to be removed. The value will be copied.
lenThe number of bytes that make up val or RU_SIZE_AUTO.
Returns
RUE_OK on success else an error code.

◆ ruFreeStore()

RUAPI void ruFreeStore ( void *  obj)

Public function to free the given KvStore object.

Parameters
objThe object to free

◆ ruNewFileStore()

RUAPI KvStore* ruNewFileStore ( const char *  folderPath,
int32_t *  code 
)

Returns a newly created file system based KvStore object. If there is already store data in the given folder, it is opened and used.

Parameters
folderPathTop level folder under which the data will be stored.
codeReturn code willbe RUE_OK on success or error otherwise.
Returns
KvStore object on success else NULL.

◆ ruNewNullStore()

RUAPI KvStore* ruNewNullStore ( void  )

Returns a newly created NULL based KvStore interface. This keystore silently ignores setters and never returns data.

Returns
KvStore object.

◆ ruNewStore()

RUAPI KvStore* ruNewStore ( void  )

Returns a generic KvStore interface. This function is mainly used by those implementing the KvStore interface.

Returns
A new empty KvStore object;

◆ ruNullStoreGet()

RUAPI int32_t ruNullStoreGet ( KvStore kvs,
const char *  key,
char **  val,
rusize len 
)

Get the value of key from the given KvStore.

Parameters
kvsKvStore context where data will be retrieved from.
keyThe kvstore key to the data in question.
valWhere the retrieved value will be stored. Will always be NULL.
lenThe number of bytes that make up val. Will always be 0.
Returns
RUE_OK on success else an error code.

◆ ruNullStoreList()

RUAPI int32_t ruNullStoreList ( KvStore kvs,
const char *  key,
ruList list 
)

Returns a list of items under given key.

Parameters
kvsKvStore context where data will be retrieved from.
keyThe kvstore key to the data in question. Should end with a *.
listA NULL ruList of keys that would normally be found.
Returns
RUE_OK on success else an error code.

◆ ruNullStoreSet()

RUAPI int32_t ruNullStoreSet ( KvStore kvs,
const char *  key,
const char *  val,
rusize  len 
)

Set the value of key in the given FileStore.

Parameters
kvsKvStore context where data will be stored.
keyThe kvstore key to the data in question.
valThe value that will be stored or NULL if the key is to be removed.
lenThe number of bytes that make up val or RU_SIZE_AUTO.
Returns
RUE_OK on success else an error code.

◆ ruValidStore()

RUAPI int32_t ruValidStore ( void *  obj)

Checks given object to be a valid KvStore object.

Parameters
objThe object to validate.
Returns
RUE_OK if valid else an errro code.