public DictionaryCacheData(int partitionCount, IEqualityComparer <TKey> keyComparer, ICacheDataSerializer serializer, int initialCap = 0) : base(partitionCount, keyComparer) { _serializer = serializer; _data = new Dictionary <TKey, TValue> [TotalSync]; for (var i = 0; i < TotalSync; i++) { _data[i] = new Dictionary <TKey, TValue>(initialCap, keyComparer); } _alreadySerialized = false; }
public HashSetCacheData(int partitionCount, IEqualityComparer <TKey> keyComparer, ICacheDataSerializer serializer) : base(partitionCount, keyComparer) { _serializer = serializer; _data = new HashSet <TKey> [TotalSync]; for (var i = 0; i < TotalSync; i++) { _data[i] = new HashSet <TKey>(keyComparer); } _alreadySerialized = false; }
private AsyncCacheData <TKey, TValue> CreateCacheDataInstance(ICacheConfigProfile config, ICacheDataSerializer serializer) { var partitions = StaticCalls.AdjustPartitionCount(config.PartitionCount); if (!config.KeyIsValue) { return(new DictionaryCacheData <TKey, TValue>(partitions, _keyComparer, serializer)); } if (typeof(TKey) == typeof(TValue)) { return(new HashSetCacheData <TKey>(partitions, _keyComparer, serializer) as AsyncCacheData <TKey, TValue>); } throw new AsyncCacheException(AsyncCacheErrorCode.InvalidConfig, $"Config sets {nameof(config.KeyIsValue)} = true. But TKey and TValue not same type."); }
private AsyncCacheData <TKey, TValue> CreateAdditionalCacheDataInstance(ICacheConfigProfile config, ICacheDataSerializer serializer) { if (config.AdType == AdditionalData.None) { return(new EmptyCacheData <TKey, TValue>(0, null)); } if (!config.KeyIsValue) { return(new DictionaryCacheData <TKey, TValue>(1, _keyComparer, serializer)); } if (typeof(TKey) == typeof(TValue)) { return(new HashSetCacheData <TKey>(1, _keyComparer, serializer) as AsyncCacheData <TKey, TValue>); } throw new AsyncCacheException(AsyncCacheErrorCode.InvalidConfig, $"Config sets {nameof(config.KeyIsValue)} = true. But TKey and TValue not same type."); }