Exemple #1
0
        public void Initialise()
        {
            basePath = WebUtility.MapPath("datastore/content-cache") + @"\";
            conn     = new SQLiteConnection(SQLiteDatabase.CreateConnectionString("datastore/content-cache/cache.s3db"));
            SQLiteDatabase.CheckFileExists(conn.ConnectionString);
            conn.Open();
            SQLiteCommand cmd = new SQLiteCommand(ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-init.sql"), conn);

            cmd.ExecuteNonQuery();
            cmd = new SQLiteCommand(ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-select-all.sql"), conn);
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                CacheItemInfo info = new CacheItemInfo(reader);
                if (File.Exists(info.PhysicalPath))
                {
                    if (info.SprocketPath != null)
                    {
                        lock (sprocketPathMemoryCache)
                            sprocketPathMemoryCache[info.SprocketPath] = info;
                    }
                    lock (memoryCache)
                        memoryCache[info.IdentifierString] = info;
                    diskSpace += info.File.Length;
                }
            }
            reader.Close();
            sqlInsert = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-insert.sql");
            sqlDelete = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-delete.sql");
            sqlDeletePartialMatches = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-delete-partial-matches.sql");
            sqlUpdate    = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-update.sql");
            sqlSelect    = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-select.sql");
            sqlSelectAll = ResourceLoader.LoadTextResource("Sprocket.Web.Cache.cache-select-from-path.sql");
        }