예제 #1
0
        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>);
            }
        }
예제 #2
0
        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);
            }
        }