A memory database based on shared memory.
shmdb shared memory multi-process aimed at resolving the problem. Under linux or windows, operating system provides a shared memory feature, you can apply for a memory area by calling the system function, shmdb is the use of this feature of the operating system, the framework of a key-value type of database. When used to set up a pair of key-value through the function shmdb_put
, also to get a pair of key-value through the function shmdb_get
.
shmdb does not provide network access functions can only be embedded into applications to run. It is not suitable for network databases.
int shmdb_initParent (STHashShareHandle * handle, unsigned int size)
Parameters
- [In | out]
STHashShareHandle * handle
shmid
,which is the member variable ofhandle
will ben initialize in this function unsigned int size
specified base area- [In]
STShmdbOption *option
the option of log,can be NULL.
The return value
- int result of the operation
int shmdb_initChild (STHashShareHandle * handle)
Parameters
-
[In]
STHashShareHandle * handle
internal memory function to mount its own memory area based to the shared memory via thehandle
'sshmid
The return value -
int
result of the operation
int shmdb_put (STHashShareHandle * handle, const char * key, unsigned short keyLen,
const char * value, unsigned short valueLen)
Parameters
- [In]
STHashShareHandle * handle
internal function to read the value of handle's shmid to manipulate shared memory - [In]
const char * key
unsigned short keyLen
- [In]
const char * value
unsigned short valueLen
The return value
int
result of the operation
shmdb_get (STHashShareHandle * handle, const char * key, unsigned short keyLen,
char ** value, unsigned short * valueLen)
Parameters
- [In]
STHashShareHandle * handle
internal function to read the value of handle's shmid to manipulate shared memory - [In]
const char * key
unsigned short keyLen
- [Out]
char ** value
internal function allocate the memory space ofvalue
, manually call thefree
function after this call is completed. IfvalueLen
value is NULL, the function does not allocate the space ofvalue
. unsigned short * valueLen
The return value
int
result of the operation
int shmdb_delete (STHashShareHandle * handle, const char * key, unsigned short keyLen,
char ** value, unsigned short * valueLen)
Parameters
- [In]
STHashShareHandle * handle
internal function to read the value of handle's shmid to manipulate shared memory - [In]
const char * key
unsigned short keyLen
- [Out]
char ** value
internal function allocate the memory space ofvalue
, manually call thefree
function after this call is completed. IfvalueLen
value is NULL, the function does not allocate the space ofvalue
. unsigned short * valueLen
The return value
int
result of the operation
When the program exits normally, you should call this function manually to remove the shared memory from the operating system.
int shmdb_destroy (STHashShareHandle * handle)
Parameters
- [In]
STHashShareHandle * handle
internal function to read the value of handle's shmid to manipulate shared memory
The return value
int
result of the operation
yunnysunny (maintainer)
License: Apache License, Version 2.0