2007-03-08 07:56:53 +00:00
|
|
|
/**
|
|
|
|
@file
|
|
|
|
|
|
|
|
Implements cache replacement policies. Eventually, this could be
|
|
|
|
extended to support application specific caching schemes.
|
|
|
|
|
|
|
|
@todo Stasis used to use LRU-2S. LRU-2S is described in Markatos
|
|
|
|
"On Caching Searching Engine Results". (This needs to be
|
|
|
|
re-implemented properly.)
|
|
|
|
|
|
|
|
For now, Stasis uses plain-old LRU. DB-MIN would be an interesting
|
|
|
|
extension.
|
|
|
|
|
|
|
|
If you would like to implement your own caching policy, implement
|
|
|
|
the functions below. They are relatively straightforward. Note
|
|
|
|
that replacementPolicy implementations do not perform any file I/O
|
|
|
|
of their own.
|
|
|
|
|
|
|
|
The implementation of this module does not need to be threadsafe.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct replacementPolicy {
|
|
|
|
struct replacementPolicy* (*init)();
|
|
|
|
void (*deinit) (struct replacementPolicy* impl);
|
2011-04-20 20:25:17 +00:00
|
|
|
void (*hit) (struct replacementPolicy* impl, Page* page);
|
|
|
|
Page* (*getStale)(struct replacementPolicy* impl);
|
|
|
|
Page* (*remove) (struct replacementPolicy* impl, Page* page);
|
|
|
|
Page* (*getStaleAndRemove)(struct replacementPolicy* impl);
|
|
|
|
void (*insert) (struct replacementPolicy* impl, Page* page);
|
2007-03-08 07:56:53 +00:00
|
|
|
void * impl;
|
|
|
|
} replacementPolicy;
|
|
|
|
|
2009-05-13 22:06:58 +00:00
|
|
|
replacementPolicy * stasis_replacement_policy_lru_init();
|
2011-04-20 20:25:17 +00:00
|
|
|
replacementPolicy * lruFastInit();
|
2009-11-09 20:53:05 +00:00
|
|
|
replacementPolicy* replacementPolicyThreadsafeWrapperInit(replacementPolicy* rp);
|
|
|
|
replacementPolicy* replacementPolicyConcurrentWrapperInit(replacementPolicy** rp, int count);
|