summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2015-11-11 20:01:48 -0500
committerGravatar Ziv Scully <ziv@mit.edu>2015-11-11 20:01:48 -0500
commit7b14b2f01fd0218c0bbe0a5c4071fff190c91ce1 (patch)
tree3d666922cee1091bb7f576127181f622cd944d88 /include
parentb7d668bb4647c4216df7120b4b8f8d5c6e8257f0 (diff)
Rewrite LRU cache. Now uses one big hash table and is less buggy.
Diffstat (limited to 'include')
-rw-r--r--include/urweb/types_cpp.h29
-rw-r--r--include/urweb/urweb_cpp.h8
2 files changed, 14 insertions, 23 deletions
diff --git a/include/urweb/types_cpp.h b/include/urweb/types_cpp.h
index 84423105..4847a3fd 100644
--- a/include/urweb/types_cpp.h
+++ b/include/urweb/types_cpp.h
@@ -123,31 +123,24 @@ typedef struct {
#include "uthash.h"
-typedef struct uw_Sqlcache_CacheValue {
+typedef struct uw_Sqlcache_Value {
char *result;
char *output;
-} uw_Sqlcache_CacheValue;
+ unsigned long timeValid;
+} uw_Sqlcache_Value;
-typedef struct uw_Sqlcache_CacheEntry {
+typedef struct uw_Sqlcache_Entry {
char *key;
- void *value;
- time_t timeValid;
- struct uw_Sqlcache_CacheEntry *prev;
- struct uw_Sqlcache_CacheEntry *next;
+ uw_Sqlcache_Value *value;
+ unsigned long timeInvalid;
UT_hash_handle hh;
-} uw_Sqlcache_CacheEntry;
-
-typedef struct uw_Sqlcache_CacheList {
- uw_Sqlcache_CacheEntry *first;
- uw_Sqlcache_CacheEntry *last;
- int size;
-} uw_Sqlcache_CacheList;
+} uw_Sqlcache_Entry;
typedef struct uw_Sqlcache_Cache {
- uw_Sqlcache_CacheEntry *table;
- time_t timeInvalid;
- uw_Sqlcache_CacheList *lru;
- int height;
+ struct uw_Sqlcache_Entry *table;
+ unsigned long timeInvalid;
+ unsigned long timeNow;
+ UT_hash_handle hh;
} uw_Sqlcache_Cache;
#endif
diff --git a/include/urweb/urweb_cpp.h b/include/urweb/urweb_cpp.h
index ab2a91c1..52e54372 100644
--- a/include/urweb/urweb_cpp.h
+++ b/include/urweb/urweb_cpp.h
@@ -405,10 +405,8 @@ void uw_Basis_writec(struct uw_context *, char);
// Sqlcache.
-#include "uthash.h"
-
-uw_Sqlcache_CacheValue *uw_Sqlcache_check(uw_Sqlcache_Cache *, char **);
-uw_Sqlcache_CacheValue *uw_Sqlcache_store(uw_Sqlcache_Cache *, char **, uw_Sqlcache_CacheValue *);
-uw_Sqlcache_CacheValue *uw_Sqlcache_flush(uw_Sqlcache_Cache *, char **);
+uw_Sqlcache_Value *uw_Sqlcache_check(uw_Sqlcache_Cache *, char **, int);
+void *uw_Sqlcache_store(uw_Sqlcache_Cache *, char **, int, uw_Sqlcache_Value *);
+void *uw_Sqlcache_flush(uw_Sqlcache_Cache *, char **, int);
#endif