diff include/urweb/types_cpp.h @ 2234:2f7ed04332a0

Progress on LRU cache but still more known bugs to fix.
author Ziv Scully <ziv@mit.edu>
date Sun, 28 Jun 2015 12:46:51 -0700
parents c93fbd139732
children 88cc0f44c940
line wrap: on
line diff
--- a/include/urweb/types_cpp.h	Wed May 06 23:11:30 2015 -0400
+++ b/include/urweb/types_cpp.h	Sun Jun 28 12:46:51 2015 -0700
@@ -119,4 +119,35 @@
   char *start, *front, *back;
 } uw_buffer;
 
+// Caching
+
+#include "uthash.h"
+
+typedef struct CacheValue {
+  char *result;
+  char *output;
+} CacheValue;
+
+typedef struct CacheEntry {
+  char *key;
+  void *value;
+  time_t timeValid;
+  struct CacheEntry *prev;
+  struct CacheEntry *next;
+  UT_hash_handle hh;
+} CacheEntry;
+
+typedef struct CacheList {
+  CacheEntry *first;
+  CacheEntry *last;
+  int size;
+} CacheList;
+
+typedef struct Cache {
+  CacheEntry *table;
+  time_t timeInvalid;
+  CacheList *lru;
+  int height;
+} Cache;
+
 #endif