Redis의 임베디드 구현. http://vedis.symisc.net
Vedis는 Redis와 개념에서 비슷한 70 개가 넘는 명령으로 구축되었지만 Vedis는 호스트 애플리케이션의 동일한 프로세스에서 실행 된 이후 네트워킹 계층이없는 임베디 가능한 Datastore C 라이브러리입니다.
대부분의 다른 데이터 저장소 (예 : Memcache, Redis)와 달리 Vedis는 별도의 서버 프로세스가 없습니다. Vedis는 일반 디스크 파일을 읽고 직접 씁니다. 여러 컬렉션이있는 완전한 데이터베이스는 단일 디스크 파일에 포함되어 있습니다. 데이터베이스 파일 형식은 크로스 플랫폼이며 32 비트와 64 비트 시스템 또는 빅 엔디 언 아키텍처 사이의 데이터베이스를 자유롭게 복사 할 수 있습니다.
Vedis는 의존하지 않는 자체 포함 C 라이브러리입니다. 외부 라이브러리 나 운영 체제에서 매우 최소한의 지원이 필요합니다. 이로 인해 데스크탑 컴퓨터의 지원 인프라가없는 임베디드 장치에 사용하기에 적합합니다. 또한 VEDIS는 다양한 구성의 다양한 컴퓨터에서 수정하지 않고 실행 해야하는 응용 프로그램 내에서 사용하기에 적합합니다.
데이터 스토어 엔진의 주요 작업은 가능한 빨리 레코드를 저장하고 검색하는 것입니다. Vedis는 구조화 된 데이터 저장 및 원시 데이터 스토리지를 모두 지원합니다.
CEI (Command Execution Interface)를 통해 구조화 된 데이터 저장소가 클라이언트에게 제공됩니다. 기본적으로 VEDIS_EXEC ()를 통해 하나 이상의 명령 ALA REDIS (예 : 키 값 설정; 키 값 GET KEY, HSET ...)를 실행하고 VEDIS_EXEC_RESULT ()를 통해 실행 결과 (명령의 리턴 값)를 추출합니다. 내장 명령 목록은 다음 페이지를 참조하십시오.
원시 데이터 저장소는 키/값 저장소 인터페이스를 통해 클라이언트에게 제공됩니다. Vedis는 Berkeley DB, Tokyo Cabinet, LevelDB 등과 유사한 표준 키/가치 저장소이지만 거래 (ACID), 동시 리더 등을 포함한 풍부한 기능 세트가 있습니다.
KV 스토어에서 키와 값이 모두 간단한 바이트 배열로 취급되므로 ASCII 문자열, 이진 블로브 및 디스크 파일에서 컨텐츠가 될 수 있습니다. KV Store 레이어는 인터페이스 세트를 통해 클라이언트에게 제공됩니다. 여기에는 Vedis_kv_store (), vedis_kv_append (), vedis_kv_fetch_callback (), vedis_kv_append_fmt () 등이 포함됩니다.
vedis *pStore; /* Datastore handle */
int rc;
/* Create our datastore */
rc = vedis_open(&pStore,argc > 1 ? argv[ 1 ] /* On-disk DB */ : " :mem: " /* In-mem DB */ );
if ( rc != VEDIS_OK ){ /* Seriously? */ return ; }
/* Execute the simplest command */
rc = vedis_exec(pStore, " SET test 'Hello World' " ,- 1 );
if ( rc != VEDIS_OK ){ /* Handle error */ }
/* Another simple command (Multiple set) */
rc = vedis_exec(pStore, " MSET username james age 27 mail [email protected] " ,- 1 );
if ( rc != VEDIS_OK ){ /* Handle error */ }
/* A quite complex command (Multiple hash set) using foreign data */
rc = vedis_exec_fmt(pStore,
" HMSET config pid %d user %s os %s scm %s " ,
1024 /* pid */ ,
" dean " , /* user */
" FreeBSD " , /* OS */
" Git " /* SCM */
);
if ( rc != VEDIS_OK ){ /* Handle error */ }
/* Fetch some data */
rc = vedis_exec(pStore, " GET test " ,- 1 );
if ( rc != VEDIS_OK ){ /* Seriously? */ }
/* Extract the return value of the last executed command (i.e. 'GET test') " */
vedis_exec_result (pStore,&pResult);
{
const char *zResponse;
/* Cast the vedis object to a string */
zResponse = vedis_value_to_string (pResult, 0 );
/* Output */
printf ( " test ==> %s n " ,zResponse); /* test ==> 'Hello world' */
}
vedis_exec (pStore, " GET mail " ,- 1 );
/* 'GET mail' return value */
vedis_exec_result (pStore,&pResult);
{
const char *zResponse;
/* Cast the vedis object to a string */
zResponse = vedis_value_to_string (pResult, 0 );
/* Output */
printf ( " mail ==> %s n " ,zResponse); /* Should be '[email protected]' */
}
/*
* A command which return multiple value in array.
*/
vedis_exec (pStore, " MGET username age " ,- 1 ); /* james 27 */
vedis_exec_result (pStore,&pResult);
if ( vedis_value_is_array(pResult) ){
/* Iterate over the elements of the returned array */
vedis_value *pEntry;
puts ( " Array entries: " );
while ((pEntry = vedis_array_next_elem (pResult)) != 0 ){
const char *zEntry;
/* Cast to string and output */
zEntry = vedis_value_to_string (pEntry, 0 );
/* Output */
printf ( " t %s n " ,zEntry);
}
}
/* Extract hashtable data */
vedis_exec (pStore, " HGET config pid " ,- 1 ); /* 1024 */
vedis_exec_result (pStore,&pResult);
{
int pid;
/* Cast to integer */
pid = vedis_value_to_int (pResult);
/* Output */
printf ( " pid ==> %d n " ,pid); /* Should be 1024 */
}
/* Finally, auto-commit the transaction and close our datastore */
vedis_close (pStore);http://vedis.symisc.net을 방문하십시오