🔗 Store API
class StoreSearch : RefCountable
{
/* callback upon a new StoreEntry being available */
virtual void next(void (callback)(void *cbdata), void *cbdata) = 0;
/* return true if a new StoreEntry is immediately available */
virtual bool next() = 0;
/* has an error occured ? */
virtual bool error() const = 0;
/* are we at the end of the iterator ? */
virtual bool isDone() const = 0;
/* retrieve the current store entry */
virtual StoreEntry *currentItem() = 0;
};
class Store : RefCountable
{
public:
RefCount<StoreSearch> search (String const url, HttpRequest * request) = 0;
};
当前类层次结构。
Store ----- StoreController
+--- StoreHashIndex
+--- SwapDir
+--- UFSSwapDir
+--- CossSwapDir
+--- NullSwapDir
当前的 squid 2.5 功能尚未改变。它们通过构建以下类实例的内存结构来实现
Store::Root() -- StoreController
|
StoreHashIndex
|
+-----------+----+------+
|
UFSSwapDir ... ... .... ...
🔗 替换策略
🔗 作为装饰器
首先是一个新类
class StoreLRU : public Store;
当我们构建内存结构时
Store::Root() -- StoreController
|
StoreHashIndex
|
+-----------+-----------+
| |
StoreLru StoreHeap ....
| |
UFSSwapDir UfsSwapDir ...
或者
Store::Root() -- StoreController
|
StoreLru
|
StoreHashIndex
|
+-----------+-----------+
| |
UFSSwapDir UfsSwapDir ...