Example #1
0
        public void Init()
        {
            algo  = new LRUreplacementAlgorithm();
            cache = new NWayAssociateSetChach(algo, 3, 8);
            TestPerson person = new TestPerson("petrov", "Петров П.П.");

            cache.Put(person.NickName, person);
            person = new TestPerson("sidorov", "Сидоров П.П.");
            cache.Put(person.NickName, person);
        }
Example #2
0
        public void TestMethodDelResentAdded()
        {
            ICacheChangeAlgorithm algo         = new MRUreplacementAlgorithm();
            NWayAssociateSetChach cache        = new NWayAssociateSetChach(algo, 4, 2);
            TestPerson            personIvanov = new TestPerson("ivanov", "Иванов И.И.");

            cache.Put(personIvanov.NickName, personIvanov);
            System.Threading.Thread.Sleep(50);
            TestPerson personPetrov = new TestPerson("petrov", "Петров П.П.");

            cache.Put(personPetrov.NickName, personPetrov);
            System.Threading.Thread.Sleep(50);
            TestPerson personSidorov = new TestPerson("sidorov", "Сидоров П.П.");

            cache.Put(personSidorov.NickName, personSidorov);
            Assert.That(cache.Get("ivanov").Equals(personIvanov));
            Assert.That(cache.Get("petrov") == null);
            Assert.That(cache.Get("sidorov").Equals(personSidorov));
        }