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. */
| 240 | * means the key should not be expired at all. Return 1 on success, or |
| 241 | * 0 on error. */ |
| 242 | int 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().*/ |
| 257 | int kvSet(sqlite3 *dbhandle,const char *key, const char *value, int64_t expire) { |