public ICache <T> GetCache <T>(string collectionName) where T : class, new() { lock (DBConnectionSync) { if (!TableExists <CollectionTableMap>(DBConnectionSync)) { DBConnectionSync.CreateTable <CollectionTableMap>(); } CollectionTableMap ctm = new CollectionTableMap { CollectionName = collectionName, TableName = typeof(T).Name }; DBConnectionSync.InsertOrReplace(ctm); if (mapCollectionToCache.ContainsKey(collectionName)) { return(mapCollectionToCache[collectionName] as ICache <T>); } mapCollectionToCache[collectionName] = new SQLiteCache <T>(collectionName, dbConnectionAsync, DBConnectionSync); return(mapCollectionToCache[collectionName] as ICache <T>); } }
public bool SetQueryCacheItem(QueryCacheItem item) { lock (DBConnectionSync) { bool success = false; if (!TableExists <QueryCacheItem>(DBConnectionSync)) { DBConnectionSync.CreateTable <QueryCacheItem>(); } int result = DBConnectionSync.InsertOrReplace(item); if (result != 0) { success = true; } return(success); } }