The class defined here implements a general memory cache for data from an arbitrary source (e.g. files, sockets, etc). It is based on the abstract definition of a cache. Use the Create() method to create instances of a cache. There can be many such instances. Each instance is associated with one or more XrdOucCacheIO objects (see the XrdOucCache::Attach() method).
Notes:
- The minimum PageSize is 4096 (4k) and must be a power of 2. The maximum PageSize is 16MB.
- The size of the cache is forced to be a multiple PageSize and have a minimum size of PageSize * 256.
- The minimum external read size is equal to PageSize.
- Currently, only write-through caches are supported.
- The Max2Cache value avoids placing data in the cache when a read exceeds the specified value. The minimum allowed is PageSize, which is also the default.
- Structured file optimization allows pages whose bytes have been fully referenced to be discarded; effectively increasing the cache.
- A structured cache treats all files as structured. By default, the cache treats files as unstructured. You can over-ride the settings on an individual file basis when the file's I/O object is attached by passing the XrdOucCache::optFIS option, if needed.
- Write-in caches are only supported for files attached with the XrdOucCache::optWIN setting. Otherwise, updates are handled with write-through operations.
- A cache object may be deleted. However, the deletion is delayed until all CacheIO objects attached to the cache are detached.
- The default maximum attached files is set to 8192 when isServer has been specified. Otherwise, it is set at 256.
- When canPreRead is specified, the cache asynchronously handles preread requests (see XrdOucCacheIO::Preread()) using 9 threads when isServer is in effect. Otherwise, 3 threads are used.
- The max queue depth for prereads is 8. When the max is exceeded the oldest preread is discarded to make room for the newest one.
- If you specify the canPreRead option when creating the cache you can also enable automatic prereads if the algorithm is workable. Otherwise, you will need to implement your own algorithm and issue prereads manually using the XrdOucCacheIO::Preread() method.
- The automatic preread algorithm is (see aprParms):
- A preread operation occurs when all of the following conditions are satisfied:
- The cache CanPreRead option is in effect.
- The read length < 'miniRead' || (read length < 'maxiRead' && Offset == next maxi offset)
- The preread page count is set to be readlen/pagesize and the preread occurs at the page after read_offset+readlen. The page is adjusted, as follows:
- If the count is < minPages, it is set to minPages.
- The count must be > 0 at this point.
- Normally, pre-read pages participate in the LRU scheme. However, if the preread was triggered using 'maxiRead' then the pages are marked for single use only. This means that the moment data is delivered from the page, the page is recycled.
- Invalid options silently force the use of the default.