Exemplo n.º 1
0
        public QueryCacheItem GetQueryCacheItem(string collectionName, string query, string lastRequest)
        {
            lock (DBConnectionSync)
            {
                QueryCacheItem result = null;

                if (!TableExists <QueryCacheItem>(DBConnectionSync))
                {
                    DBConnectionSync.CreateTable <QueryCacheItem>();
                }
                else
                {
                    var items = DBConnectionSync.Table <QueryCacheItem>().Where(item => item.collectionName == collectionName && item.query == query);
                    if (items.Count() == 1)
                    {
                        foreach (QueryCacheItem item in items)
                        {
                            result = item;
                        }
                    }
                }

                return(result);
            }
        }
Exemplo n.º 2
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>);
            }
        }
Exemplo n.º 3
0
        public ISyncQueue GetSyncQueue(string collectionName)
        {
            lock (DBConnectionSync)
            {
                if (!TableExists <PendingWriteAction>(DBConnectionSync))
                {
                    DBConnectionSync.CreateTable <PendingWriteAction>();
                }

                return(new SQLiteSyncQueue(collectionName, DBConnectionSync));
            }
        }
Exemplo n.º 4
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);
            }
        }