Reputation: 12437
I have been looking online and have been reading that you cant use HttpContext.Current.Cache
in a signalR hub class, so what would be the workaround if i wanted to be able to have each user have some cache data that is accessed in my hub methods.
EDIT:
This data would only need to be used inside my hub class, I would not need to access it elsewhere in my asp.net application. It would definitely need to be user specific though.
Upvotes: 5
Views: 5304
Reputation: 33379
If you're only looking for the equivalent capabilities of the built in ASP.NET cache then you can simply spin up a static instance of System.Runtime.Caching.MemoryCache
class. Then just access the static instance in your various hub methods.
Keep in mind this is a single server, in-memory solution. For more advanced, out of process, distributed caching solutions I would look to AppFabric (Azure or on-premises) or Memcached.
Upvotes: 8