Hi,
Does anyone know any implementation of a templated cache of objects?
- You use a key to find object (the same as in std::map<>)
- You specify a maximum number of objects that can be in the cache at the same time
- There are facilities to create an object not found in the cache
- There are facilities to know when an object is discarded from the cache
For example :
typedef cache<int, MyObj*> MyCache;
MyCache oCache;
oCache.SetSize(1);
oCache.Insert(make_pair(1, new MyObj());
oCache.Touch(1);
MyObj* oldObj = oCache.Delete(1);
...
It can be as simple as a LRU or MRU cache.
Any suggestions are welcomed!
Nic