Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion BitFaster.Caching.ThroughputAnalysis/MemoryCacheAdaptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class MemoryCacheAdaptor<K, V> : ICache<K, V>
{
MemoryCacheOptionsAccessor accessor;
MemoryCache exMemoryCache;
CachePolicy policy;

public MemoryCacheAdaptor(int capacity)
{
accessor = new MemoryCacheOptionsAccessor();
accessor.Value.SizeLimit = capacity;

exMemoryCache = new MemoryCache(accessor);
policy = new CachePolicy(new Optional<IBoundedPolicy>(new BoundedPolicy(capacity)), Optional<ITimePolicy>.None());
}

public int Count => throw new NotImplementedException();
Expand All @@ -27,7 +29,7 @@ public MemoryCacheAdaptor(int capacity)

public Optional<ICacheEvents<K, V>> Events => throw new NotImplementedException();

public CachePolicy Policy => throw new NotImplementedException();
public CachePolicy Policy => this.policy;

public ICollection<K> Keys => throw new NotImplementedException();

Expand Down Expand Up @@ -81,6 +83,23 @@ IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}

private class BoundedPolicy : IBoundedPolicy
{
private int capacity;

public BoundedPolicy(int capacity)
{
this.capacity = capacity;
}

public int Capacity => this.capacity;

public void Trim(int itemCount)
{
throw new NotImplementedException();
}
}
}

public class MemoryCacheOptionsAccessor
Expand Down