Getting the following exception when trying to pull an object out of the cache, it was added fine
this is what it added to the cache
Getting the following exception when trying to pull an object out of the cache, it was added fine
This points to a mismatch in the type of object being added to cache vs how it's being gotten from cache. The cache methods are strongly typed now, relying on generic methods for ensuring the same type is added/pulled from cache.
In particular:
// given an object of type nullable LastReadPostInfo...
FourRoads.VerintCommunity.ForumLastPost.Interfaces.LastReadPostInfo? lastReadPostInfo = null;
Telligent.Evolution.Extensibility.Caching.Version1.CacheService.Put("my-key", CacheScope.Process, lastReadPostInfo); ;
// Retrieve from cache with same nullable type
if (Telligent.Evolution.Extensibility.Caching.Version1.CacheService.TryGet<FourRoads.VerintCommunity.ForumLastPost.Interfaces.LastReadPostInfo?>("my-key", CacheScope.Process, out var cachedLastReadPostInfo))
{
// do something with cachedLastReadPostInfo
}Incidentally, we're reviewing our options with potentially de-obfuscating portions of logged exception stacks.
It's inside this method, which does what you are doing above, the key is quite complex, but I can't see how that would cause a cast issue
public T Get<T>(string key)
{
CacheService.TryGet<T>(key, CacheScope.All, out T result);
return result;
}


The Get is fine. But it still likely means it's being put in the cache as an Object, not a Nullable<LastReadPostInfo>.
And as you're specifying CacheScope.All, make sure there's a corresponding IDistributedCacheSerializationProvider Plugin Type .
And as you're specifying CacheScope.All, make sure there's a corresponding IDistributedCacheSerializationProvider Plugin Type .