static void Main() { // This sample shows the use of FASTER as a concurrent pure in-memory cache var log = new NullDevice(); // no storage involved // Define settings for log var logSettings = new LogSettings { LogDevice = log, ObjectLogDevice = log, MutableFraction = 0.9, // 10% of memory log is "read-only region" CopyReadsToTail = CopyReadsToTail.FromReadOnly, // reads in read-only region are copied to tail PageSizeBits = 14, // Each page is sized at 2^14 bytes MemorySizeBits = 25, // (2^25 / 24) = ~1.39M key-value pairs (log uses 24 bytes per KV pair) }; // Number of records in memory, assuming class keys and values and x64 platform // (8-byte key + 8-byte value + 8-byte header = 24 bytes per record) int numRecords = (int)(Math.Pow(2, logSettings.MemorySizeBits) / 24); // Targeting 1 record per bucket var numBucketBits = (int)Math.Ceiling(Math.Log2(numRecords)); h = new FasterKV <CacheKey, CacheValue>(1L << numBucketBits, logSettings, comparer: new CacheKey()); sizeTracker = new CacheSizeTracker(h, logSettings.MemorySizeBits); PopulateStore(numRecords); ContinuousRandomWorkload(); h.Dispose(); Console.WriteLine("Press <ENTER> to end"); Console.ReadLine(); }
public CacheFunctions(CacheSizeTracker sizeTracker) { this.sizeTracker = sizeTracker; }