aboutsummaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2019-10-14 12:25:35 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2019-10-15 22:06:24 +0200
commitf53a76ce91ab83c7345a104b57f148738101c58d (patch)
tree90fae562195d8030903828e0319693fbe880dfd8 /src/cache.c
parentb5fdd44014207c619b937e5c202ba27e77a2593c (diff)
Transmit expiration in relative values
This will at the end allow unsynchronized clients to query the server efficiently. Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cache.c b/src/cache.c
index d14e877..c3f83cc 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -274,11 +274,11 @@ search(
/* see cache.h */
int
-cache_put(
- cache_t *cache,
+cache_put(cache_t *cache,
const cynagora_key_t *key,
int value,
- time_t expire
+ time_t expire,
+ bool absolute
) {
uint16_t length;
item_t *item;
@@ -308,7 +308,7 @@ cache_put(
stpcpy(1 + stpcpy(1 + stpcpy(1 + stpcpy(item->strings, key->client), key->session), key->user), key->permission);
cache->used += (uint32_t)size;
}
- item->expire = expire;
+ item->expire = !expire ? 0 : absolute ? expire : expire + time(NULL);
item->hit = 255;
item->value = (int8_t)value;
return 0;