MCPcopy Create free account
hub / github.com/antirez/botlib / kvSetLen

Function kvSetLen

sqlite_wrap.c:242–254  ·  view source on GitHub ↗

Set the key to the specified value and expire time. An expire of zero * means the key should not be expired at all. Return 1 on success, or * 0 on error. */

Source from the content-addressed store, hash-verified

240 * means the key should not be expired at all. Return 1 on success, or
241 * 0 on error. */
242int kvSetLen(sqlite3 *dbhandle, const char *key, const char *value, size_t vlen, int64_t expire) {
243 if (expire) expire += time(NULL);
244 if (!sqlInsert(dbhandle,"INSERT INTO KeyValue VALUES(?i,?s,?b)",
245 expire,key,value,vlen))
246 {
247 if (!sqlQuery(dbhandle,"UPDATE KeyValue SET expire=?i,value=?b WHERE key=?s",
248 expire,value,vlen,key))
249 {
250 return 0;
251 }
252 }
253 return 1;
254}
255
256/* Wrapper where the value len is obtained via strlen().*/
257int kvSet(sqlite3 *dbhandle,const char *key, const char *value, int64_t expire) {

Callers 1

kvSetFunction · 0.85

Calls 2

sqlInsertFunction · 0.85
sqlQueryFunction · 0.85

Tested by

no test coverage detected