Beispiel #1
0
        public void Exists_EnsureValueIsStoredInTheCache()
        {
            var c = new CacheLite();

            c.Set("id1", "Scooby Doo", TimeSpan.MaxValue);

            Assert.IsTrue(c.Exists("id1"));
        }
Beispiel #2
0
        public void Set_EnsureValueIsStoredInTheCache()
        {
            var c = new CacheLite();

            c.Set("id1", "Scooby Doo", TimeSpan.MaxValue);

            Assert.AreEqual("Scooby Doo", c.Get <string>("id1"));
        }
Beispiel #3
0
 static DataService()
 {
     providerFactoriesCache = new CacheLite<string, DbProviderFactory>(providerName => DbProviderFactories.GetFactory(providerName));
     EntityLiteProviderFactories.Add(SqlServerEntityLiteProvider.ProviderName, (ds) => new SqlServerEntityLiteProvider(ds));
     EntityLiteProviderFactories.Add(SqliteEntityLiteProvider.ProviderName, (ds) => new SqliteEntityLiteProvider(ds));
     EntityLiteProviderFactories.Add(MySqlEntityLiteProvider.ProviderName, (ds) => new MySqlEntityLiteProvider(ds));
     EntityLiteProviderFactories.Add(OracleEntityLiteProvider.ProviderName, (ds) => new OracleEntityLiteProvider(ds));
     EntityLiteProviderFactories.Add(NpgsqlEntityLiteProvider.ProviderName, (ds) => new NpgsqlEntityLiteProvider(ds));
 }
Beispiel #4
0
        public void Clear_EnsureItemIsRemovedFromTheCache()
        {
            var c = new CacheLite();

            c.Set("id1", "Scooby Doo", TimeSpan.MaxValue);
            c.Clear();

            Assert.IsFalse(c.Exists("id1"));
        }
Beispiel #5
0
        public void ScheduledExpiry_EnsureItemRemoved()
        {
            var scheduler = new CacheScheduler(TimeSpan.FromSeconds(5));
            var c         = new CacheLite(scheduler);

            c.Set("id1", "Scooby Doo", TimeSpan.FromSeconds(1));

            // force an update
            scheduler.Update();

            Assert.IsFalse(c.Exists("id1"));
        }