Mercurial > urweb
comparison include/urweb/types_cpp.h @ 2279:32a407902d3b
Rewrite LRU cache. Now uses one big hash table and is less buggy.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Wed, 11 Nov 2015 20:01:48 -0500 |
parents | c275bbc41194 |
children | 75cb60a7f6f1 |
comparison
equal
deleted
inserted
replaced
2278:b7615e0ac4b0 | 2279:32a407902d3b |
---|---|
121 | 121 |
122 // Caching | 122 // Caching |
123 | 123 |
124 #include "uthash.h" | 124 #include "uthash.h" |
125 | 125 |
126 typedef struct uw_Sqlcache_CacheValue { | 126 typedef struct uw_Sqlcache_Value { |
127 char *result; | 127 char *result; |
128 char *output; | 128 char *output; |
129 } uw_Sqlcache_CacheValue; | 129 unsigned long timeValid; |
130 } uw_Sqlcache_Value; | |
130 | 131 |
131 typedef struct uw_Sqlcache_CacheEntry { | 132 typedef struct uw_Sqlcache_Entry { |
132 char *key; | 133 char *key; |
133 void *value; | 134 uw_Sqlcache_Value *value; |
134 time_t timeValid; | 135 unsigned long timeInvalid; |
135 struct uw_Sqlcache_CacheEntry *prev; | |
136 struct uw_Sqlcache_CacheEntry *next; | |
137 UT_hash_handle hh; | 136 UT_hash_handle hh; |
138 } uw_Sqlcache_CacheEntry; | 137 } uw_Sqlcache_Entry; |
139 | |
140 typedef struct uw_Sqlcache_CacheList { | |
141 uw_Sqlcache_CacheEntry *first; | |
142 uw_Sqlcache_CacheEntry *last; | |
143 int size; | |
144 } uw_Sqlcache_CacheList; | |
145 | 138 |
146 typedef struct uw_Sqlcache_Cache { | 139 typedef struct uw_Sqlcache_Cache { |
147 uw_Sqlcache_CacheEntry *table; | 140 struct uw_Sqlcache_Entry *table; |
148 time_t timeInvalid; | 141 unsigned long timeInvalid; |
149 uw_Sqlcache_CacheList *lru; | 142 unsigned long timeNow; |
150 int height; | 143 UT_hash_handle hh; |
151 } uw_Sqlcache_Cache; | 144 } uw_Sqlcache_Cache; |
152 | 145 |
153 #endif | 146 #endif |