Assets/Watson/Scripts/Utilities/Utility.cs
/// <summary>
/// Get value from the data cache.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dictionaryCache"></param>
/// <param name="cacheDirectoryId"></param>
/// <param name="cacheId"></param>
/// <param name="prefix"></param>
/// <returns></returns>
Get value from the data cache.
Get value from the data cache .
public static T GetFromCache<T>(Dictionary<string,DataCache> dictionaryCache, string cacheDirectoryId, string cacheId, string prefix="") where T : class, new()
        {
            T cachedObject = null;
            DataCache cache = null;
            if (! dictionaryCache.TryGetValue( cacheDirectoryId, out cache ) )
            {
                cache = new DataCache( prefix + cacheDirectoryId );
                dictionaryCache[ cacheDirectoryId ] = cache;
            }
            byte [] cached = cache.Find( cacheId );
            if ( cached != null )
            {
                cachedObject = DeserializeResponse<T>( cached );
                if ( cachedObject != null)
                {
                    return cachedObject;
                }
            }
            return cachedObject;
        }
public static T GetFromCache < T > ( Dictionary < string , DataCache > dictionaryCache , string cacheDirectoryId , string cacheId , string prefix = " " ) where T : class , new ( ) { T cachedObject = null ; DataCache cache = null ; if ( ! dictionaryCache . TryGetValue ( cacheDirectoryId , out cache ) ) { cache = new DataCache ( prefix + cacheDirectoryId ) ; dictionaryCache [ cacheDirectoryId ] = cache ; } byte [ ] cached = cache . Find ( cacheId ) ; if ( cached != null ) { cachedObject = DeserializeResponse < T > ( cached ) ; if ( cachedObject != null ) { return cachedObject ; } } return cachedObject ; }
Get value from the data cache.
Get value from the data cache .
None
dictionaryCache
Dictionary<string,DataCache>
None
cacheDirectoryId
string
None
cacheId
string
None
prefix
string
None
typeparam
None