Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache.
Syntax
Visual Basic (Declaration) | |
---|
Public Property CacheKeepAliveMinimumHistory As Integer |
C# | |
---|
public int CacheKeepAliveMinimumHistory {get; set;} |
Example
BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs
C# | Copy Code |
---|
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;
options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;
options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;
options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;
using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
Exception lastError = null;
work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };
for (int i = 0; i < Environment.ProcessorCount; i++)
work.Enqueue(new ThreadedTest(dictionary, 1000).Run);
Assert.IsTrue(work.Complete(true, 60000));
Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
} |
VB.NET | Copy Code |
---|
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
Const keysize As Integer = 16 + 4
Const valuesize As Integer = keysize + 256 + 44
options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk
options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200
options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000
Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
Using work As New WorkQueue(Environment.ProcessorCount)
Dim lastError As Exception = Nothing
work.OnError += Function(o As Object, e As ErrorEventArgs) Do
lastError = e.GetException()
End Function
Dim i As Integer = 0
While i < Environment.ProcessorCount
work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Assert.IsTrue(work.Complete(True, 60000))
Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also