/// <summary> /// Save an Object as string /// </summary> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TValue"></typeparam> /// <param name="store"></param> /// <param name="key"></param> /// <param name="objectToBeStored"></param> /// <param name="token"></param> /// <returns></returns> public static Task SerializeAndSaveObjectInStoreAsync <TKey, TValue>( this IPersistentStore <TKey, string> store, TKey key, TValue objectToBeStored, CancellationToken token) { Assert.IsNotNull(key, "key != null"); Assert.IsFalse(objectToBeStored == null, "objectToBeStored != null"); return(store.SetEntityAsync(key, InsightsUtil.Serialize(objectToBeStored), token)); }
public static async Task <TOutput> CreateOrRetriveRetreiveObjectFromStoreAsync <TOutput, TKey>( this IPersistentStore <TKey, string> store, TKey key, TOutput defaultVal, CancellationToken token) { await store.SetIfNotPresentAsync(key, InsightsUtil.Serialize(defaultVal), token).ConfigureAwait(false); var deserialized = await store.GetEntityAsync(key, token).ConfigureAwait(false); return(InsightsUtil.DeSerialize <TOutput>(deserialized)); }