1 Star 0 Fork 4.9K

罗小黑 / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Kv_store.md 10.07 KB
一键复制 编辑 原始数据 按行查看 历史
wenjun 提交于 2020-09-08 10:08 . add OpenHarmony 1.0 baseline

Kv_store

Overview

Provides functions for obtaining, setting, and deleting a key-value pair.

Key-value pairs can be permanently stored in the file system. If FEATURE_KV_CACHE is enabled, key-value pairs can be stored in the cache. For details about cache specifications, see MAX_CACHE_SIZE. For details about the number of key-value pairs that can be stored in an application, see MAX_KV_SUM.

Since:

1.0

Version:

1.0

Summary

Files

File Name

Description

kv_store.h

Provides functions for obtaining, setting, and deleting a key-value pair.

Functions

Function Name

Description

UtilsGetValue (const char *key, char *value, unsigned int len)

int 

Obtains the value matching a specified key from the file system or cache.

UtilsSetValue (const char *key, const char *value)

int 

Adds or updates the value matching a specified key in the file system or cache.

UtilsDeleteValue (const char *key)

int 

Deletes the value matching a specified key from the file system or cache.

ClearKVCache (void)

int 

Clears all key-value pairs from the cache.

Details

Function Documentation

ClearKVCache()

int ClearKVCache (void )

Description:

Clears all key-value pairs from the cache.

Attention:

This function is available only if FEATURE_KV_CACHE is enabled.

Returns:

Returns 0 if the operation is successful; returns -1 otherwise.

UtilsDeleteValue()

int UtilsDeleteValue (const char * key)

Description:

Deletes the value matching a specified key from the file system or cache.

Parameters:

Name

Description

key Indicates the key whose value is to be deleted. It allows only lowercase letters, digits, underscores (_), and dots (.). Its length cannot exceed 32 bytes (including the end-of-text character in the string).

Returns:

Returns 0 if the operation is successful; returns -9 if a parameter is incorrect; returns -1 in other scenarios.

UtilsGetValue()

int UtilsGetValue (const char * key, char * value, unsigned int len )

Description:

Obtains the value matching a specified key from the file system or cache.

Parameters:

Name

Description

key Indicates the key to be indexed. It allows only lowercase letters, digits, underscores (_), and dots (.). Its length cannot exceed 32 bytes (including the end-of-text character in the string).
value Indicates the buffer for storing the value that matches the key. This is an output parameter.
len Indicates the size of the value space in the buffer.

Returns:

Returns the length of the value if the operation is successful; returns -9 if a parameter is incorrect; returns -1 in other scenarios; returns 0 if the value is obtained from the cache.

UtilsSetValue()

int UtilsSetValue (const char * key, const char * value )

Description:

Adds or updates the value matching a specified key in the file system or cache.

Parameters:

Name

Description

key Indicates the key whose value is to be added or updated. It allows only lowercase letters, digits, underscores (_), and dots (.). Its length cannot exceed 32 bytes (including the end-of-text character in the string).
value Indicates the value to be added or updated. Its length cannot exceed 128 bytes (including the end-of-text character in the string).

Returns:

Returns 0 if the operation is successful; returns -9 if a parameter is incorrect; returns -1 in other scenarios.

1
https://gitee.com/lawguiren/docs.git
git@gitee.com:lawguiren/docs.git
lawguiren
docs
docs
master

搜索帮助