-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added StoreCache
#3701
base: master
Are you sure you want to change the base?
Added StoreCache
#3701
Conversation
do you mind to briefly explain why your cache is more efficient? |
Weak references are useful for Suppose a tree view in a Windows Forms application displays a complex hierarchical choice of options to the user. If the underlying data is large, keeping the tree in memory is inefficient when the user is involved with something else in the application. When the user switches away to another part of the application, you can use the WeakReference class to create a weak reference to the tree and destroy all strong references. When the user switches back to the tree, the application attempts to obtain a strong reference to the tree and, if successful, avoids reconstructing the tree. Reference: https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/weak-references Also uses a write-through caching to the |
|
||
namespace Neo.Collections.Caching | ||
{ | ||
public class StoreCache<TKey, TValue>(IStore store) : ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue>, ICollection, IDictionary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long.
Changing these keys, values and comparer is not enough?
Why create a new Store? |
If your plan is optimize |
The goal is to deprecate those classes. I would of added this in |
[MemoryDiagnoser] // Enabling Memory Diagnostics | ||
[CsvMeasurementsExporter] // Export results in CSV format | ||
[MarkdownExporter] // Exporting results in Markdown format | ||
public class Benchmarks_StoreCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the benchmarks are not the same but changing the interface? it looks like the methods are totally different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods do the same thing. However, StoreCache
class is a collection, so you can convert StoreCache
to any collection you want. This is how DataCache
and other classes in neo
should of been developed.
StoreCache
inherits from
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
IEnumerable
IDictionary<TKey, TValue>
IReadOnlyCollection<KeyValuePair<TKey, TValue>>
IReadOnlyDictionary<TKey, TValue>
ICollection
IDictionary
…8/neo into fix/storage-caching
This is with optimizations to code.
Running on a Raspberry Pi 4 model B
|
If the key is faster with |
I added StorageCacheNote: this class needs more features and optimizations for better performance. Features
Expiration Tracking
|
Description
This is a benchmark of my
StoreCache
vs.DataCache
. Let know if I am missing functionality or features.StorageCache
Note: this class needs more features and optimizations for better performance.
Features
IStore
data.Expiration Tracking
@shargon @Jim8y @nan01ab
I need some input on this for new feature and what you think.
Benchmark
Type of change
How Has This Been Tested?
UT_StoreCache.TestAddAndGetSync
UT_StoreCache.TestStoreCacheGetNonCachedData
Checklist: