Skip to content
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

defaultDatabase number specified in redis connection string not honoured #175

Closed
chai-deshpande opened this issue Jul 4, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@chai-deshpande
Copy link

I am trying to use the redis cache using the connection string approach and the defaultDatabase that I have specified in the connection string is not getting picked up when caching the data in redis.

My configuration looks like this:

  <cacheManager xmlns="http:https://cachemanager.michaco.net/schemas/CacheManagerCfg.xsd">
    <managers>
      <cache name="distributed-data-cache" enableStatistics="true" backplaneName="redis.cache" backplaneType="CacheManager.Redis.RedisCacheBackplane, CacheManager.StackExchange.Redis" serializerType="CacheManager.Serialization.Json.JsonCacheSerializer, CacheManager.Serialization.Json">
        <handle name="default" ref="inmemoryHandle" />
        <handle name="redis.cache" ref="redisHandle" isBackplaneSource="true" />
      </cache>
      <cache name="inmemory-data-cache" enableStatistics="true" serializerType="CacheManager.Serialization.Json.JsonCacheSerializer, CacheManager.Serialization.Json">
        <handle name="default" ref="inmemoryHandle" />
      </cache>
    </managers>
    <cacheHandles>
      <handleDef id="inmemoryHandle" type="CacheManager.SystemRuntimeCaching.MemoryCacheHandle`1, CacheManager.SystemRuntimeCaching" defaultExpirationMode="Sliding" defaultTimeout="2m" />
      <handleDef id="redisHandle" type="CacheManager.Redis.RedisCacheHandle`1, CacheManager.StackExchange.Redis" defaultExpirationMode="Sliding" defaultTimeout="5m" />
    </cacheHandles>
  </cacheManager>

Connection string is specified like this:

  <connectionStrings>
    <add name="redis.cache" connectionString="127.0.0.1:6379,allowAdmin=False,connectTimeout=500,defaultDatabase=3,ssl=False,abortConnect=False,connectRetry=3" />
  </connectionStrings>

With this configuration - I expect the data to be written to database 3 in redis. However, it is getting written to database 0.

@MichaCo MichaCo self-assigned this Jul 9, 2017
@MichaCo MichaCo added this to the 1.2.0 milestone Jul 9, 2017
@MichaCo
Copy link
Owner

MichaCo commented Jul 9, 2017

Hi @chai-deshpande
Thanks for reporting, yeah that's true, the defaultDatabase flag was recently added to the client library and I never changed the configuration initialization to respect it. Most of the configuration options of CacheManager provide a way to define the database already, except using <connectionStrings> section...

Anyways, this will be fixed in the next version.
Until then, as a workaround, you can use one of the other options, like the CacheManager's redis configuration section, by code or MS Configuration Extensions.

Thanks,
Michael

@chai-deshpande
Copy link
Author

Thanks @MichaCo
Looking forward to the next release.

@mchudinov
Copy link

Thank you Michael! I'm waiting for this feature too.

@erizzo
Copy link

erizzo commented Oct 12, 2017

Is there an example of configuring this via code? I, too, need to specify a database other than db0.
Update I found it, should have looked closely before asking. There's an optional parameter to the WithRedisConfiguration() method: int database = 0

@MichaCo
Copy link
Owner

MichaCo commented Nov 18, 2017

fixed in release 1.1.2

@MichaCo MichaCo closed this as completed Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants