0

I've recently migrated my code away from a just using a distributed cache to using the CacheManager for 2 layers of caching to increase speed across my applications.

I'm using InMemory and Redis as a backplane.

All is working good so far as InMemory and storing the information back to Redis is concerned but I'm struggling with invalidating the cache and seeing new information.

I have a console application which runs on the server which performs updates to data then uses the AddOrUpdate method in CacheManager to push new data to the caches.

The problem is that my front end API is seeing stale data and doesn't update.

I know the console application was working previously as it was all working on the distributed caching and it would update frequently.

I've logged into Redis and I've checked if there are any subscribers to the PUBSUB channel and there aren't; should there be?

Both my console application and the API are using the same version of the library and also using the same cache configuration. Configuration is below.

{
  "$schema": "http://cachemanager.michaco.net/schemas/cachemanager.json#",
  "redis": [
    {
      "key": "redisConnection",
      "connectionString": "x.x.x.x, allowAdmin=true"
    }
  ],
  "cacheManagers": [
    {
      "maxRetries": 1000,
      "name": "masterCache",
      "retryTimeout": 100,
      "updateMode": "Up",
      "backplane": {
        "key": "redisConnection",
        "knownType": "Redis",
        "channelName": "redisChannel"
      },
      "loggerFactory": {
        "knownType": "Microsoft"
      },
      "serializer": {
        "knownType": "Json"
      },
      "handles": [
        {
          "knownType": "SystemRuntime",
          "isBackplaneSource": false,
          "name": "systemCache"
        },
        {
          "knownType": "Redis",
          "key": "redisConnection",
          "isBackplaneSource": true
        }
      ]
    }
  ] 
}

Also the results of checking the number of subscribers in Redis

127.0.0.1:6379> pubsub channels *
1) "redisChannel"
2) "__Booksleeve_MasterChanged"
127.0.0.1:6379> pubsub numsub 1
1) "1"
2) (integer) 0
Chris Lomax
  • 137
  • 2
  • 12
  • `pubsub numbsub` takes the channel name as parameter, not an interger. Try `pubsub numbsub redisChannel`. And yes, you should see a counter > 0 if any client is connected. – MichaC Mar 07 '19 at 22:17
  • OK, thanks for that. Bit of confusion when it was referencing the "N" in the arguments list on the Redis site It is returning 1 connected client now when I run that command although I'm not seeing updates still when pushing new data. The site itself is an Angular site over an API which is polled. My previous code worked that just used the distributed cache but this one doesn't seem to update unless I clear all keys in Redis and reset the app pool on the server. Any ideas? – Chris Lomax Mar 08 '19 at 09:47
  • It should have 2 connected clients, your website and your command line app – MichaC Mar 09 '19 at 02:02
  • 1
    I was doing a host of stupid things which made this not work. I hadn't updated Newtonsoft in the client, I hadn't included the Microsoft Extensions and there were a few other libraries which were outdated. After rectifying my stupid mistakes, all is working well – Chris Lomax Mar 19 '19 at 09:03

0 Answers0