Menu

[r320]: / framework / branches / cache / thread_cache.h  Maximize  Restore  History

Download this file

50 lines (43 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef THREAD_CHACHE_H
#define THREAD_CHACHE_H
#include "base_cache.h"
#include "pthread.h"
#include <map>
#include <list>
namespace cppcms {
using namespace std;
class thread_cache : public base_cache {
pthread_mutex_t lru_mutex;
pthread_rwlock_t access_lock;
struct container {
string data;
typedef map<string,container>::iterator pointer;
list<pointer>::iterator lru;
list<multimap<string,pointer>::iterator> triggers;
multimap<time_t,pointer>::iterator timeout;
};
typedef container::pointer pointer;
map<string,container> primary;
multimap<string,pointer> triggers;
typedef multimap<string,pointer>::iterator triggers_ptr;
multimap<time_t,pointer> timeout;
typedef multimap<time_t,pointer>::iterator timeout_ptr;
list<pointer> lru;
typedef list<pointer>::iterator lru_ptr;
unsigned limit;
string *get(string const &key,set<string> *triggers);
void delete_node(pointer p);
public:
thread_cache(unsigned pages=0) : limit(pages) {
pthread_mutex_init(&lru_mutex,NULL);
pthread_rwlock_init(&access_lock,NULL);
};
void set_size(unsigned l) { limit=l; };
virtual bool fetch_page(string const &key,string &output,bool gzip);
virtual bool fetch(string const &key,archive &a,set<string> &tags);
virtual void rise(string const &trigger);
virtual void store(string const &key,set<string> const &triggers,time_t timeout,archive const &a);
virtual ~thread_cache();
};
}
#endif
MongoDB Logo MongoDB