An index cache keeps a pool of indexes open for faster searching
File: dten600.idl
Module: COM Interface
Property |
Description |
---|---|
Number of seconds before an unused index can be closed automatically. | |
Number of seconds an index can be left open before it is automatically closed and reopened. | |
Number of open indexes that are currently in use | |
Maximum number of indexes to keep in the cache | |
Number of indexes currently open in the cache |
Property |
Description |
---|---|
Number of seconds before an unused index can be closed automatically. | |
Number of seconds an index can be left open before it is automatically closed and reopened. | |
Number of open indexes that are currently in use | |
Maximum number of indexes to keep in the cache | |
Number of indexes currently open in the cache |
An index cache can make searching substantially faster when a series of searches must be executed against a small number of indexes. The index cache maintains a pool of open indexes that will be available for searching on any thread. This eliminates the need to open and close the indexes being searched for every search request.
- Call Server.NewIndexCache to create an IndexCache
- Call SearchJob.SetIndexCache to assign the cache to a SearchJob
An application should generally create a single index cache before executing its first search, and should delete the index cache only after the last search is done and the last search results object has been deleted.
Deleting an IndexCache object while a search is executing can cause a crash or a memory leak. Additionally, a search results object inherits the cache used in a search, so all search results objects must also be deleted before deleting the index cache.
To prevent indexes from remaining in the cache indefinitely, use IndexCache.AutoCloseTime to specify a maximum number of seconds before unused indexes are automatically closed. Another setting, IndexCache.AutoReopenTime, can be used to ensure that even heavily-used indexes are periodically closed and reopened to refresh their view of the index contents.
The cache does not have its own thread to implement AutoCloseTime or AutoReopenTime, so it only checks AutoCloseTime and AutoReopenTime when the cache is accessed for any reason, including a calls to read the OpenIndexCount and InUseCount properties.
Index caches are thread-safe, so any number of concurrent searches can share a single IndexCache.
The same index may be open any number of times in an index cache. For example, if you have three concurrent threads searching c:\SampleIndex, and if the cache size is set to three indexes, then the cache will contain three open indexes all referencing c:\SampleIndex.
A search job will try to obtain each index to search from the cache. If an open index is available, the search job will use it for the duration of the search and return it to the cache when the search is done.
If an index cache does not have any available indexes for a search, the search will create its own private open index to process the search, just as it would have done if there was no index cache. Therefore, attaching an index cache to a search job will not cause the search to fail due to an insufficient cache size, nor can it make searching slower than it would be without a cache.