Создание RedisCacheProviderWithAsync: RedisCacheProvider - PullRequest
0 голосов
/ 26 ноября 2018

В данный момент пытаюсь создать RedisCacheProvider для Nhibernate, где более новая версия ICache ищет методы GetAsync (..).Теперь я унаследован от RedisCacheProvider, а затем переопределил его 'ICache BuildCache (...)':

    public new ICache BuildCache(string regionName, IDictionary<string, string> properties)
    {
        if (RedisCacheProviderWithAsync.connectionMultiplexerStatic == null)
            throw new InvalidOperationException("A 'ConnectionMultiplexer' must be configured with SetConnectionMultiplexer(). For example, call 'RedisCacheProvider.SetConnectionMultiplexer(ConnectionMultiplexer.Connect(\"localhost:6379\"))' before creating the ISessionFactory.");
        if (RedisCacheProviderWithAsync.optionsStatic == null)
        {
            lock (RedisCacheProviderWithAsync.syncRoot)
            {
                if (RedisCacheProviderWithAsync.optionsStatic == null)
                    RedisCacheProviderWithAsync.optionsStatic = new RedisCacheProviderOptions();
            }
        }
        if (RedisCacheProviderWithAsync.log.IsDebugEnabled)
        {
            StringBuilder stringBuilder = new StringBuilder();
            foreach (KeyValuePair<string, string> property in (IEnumerable<KeyValuePair<string, string>>)properties)
            {
                stringBuilder.Append("name=");
                stringBuilder.Append(property.Key);
                stringBuilder.Append("&value=");
                stringBuilder.Append(property.Value);
                stringBuilder.Append(";");
            }
            RedisCacheProviderWithAsync.log.Debug((object)("building cache with region: " + regionName + ", properties: " + (object)stringBuilder));
        }
        RedisCacheElement configElement = (RedisCacheElement)null;
        if (!string.IsNullOrWhiteSpace(regionName))
            configElement = RedisCacheProviderWithAsync.providerSection.Caches[regionName];
        return BuildCacheNew(regionName, properties, configElement, RedisCacheProviderWithAsync.connectionMultiplexerStatic, RedisCacheProviderWithAsync.optionsStatic);
    }

И затем мой новый производный класс

    public class RedisCacheWithAsync : RedisCache , ICache

, который реализует ICacheкак этого хотел Nhibernate 5. Но у меня есть исключения вроде этого: «RedisCache не реализует GetAsync ...», но почему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...