Esempio n. 1
0
        private void CleanUp()
        {
            lock (this)
            {
                this.UpdateAccessCounts();
                int count = base.Size() / 2;
                int accessCountCeiling = this.GetAccessCountCeiling(count, count / 8);
                BaseHashMap <int, ICachedObject, ICachedObject, ICachedObject> .BaseHashIterator <int, ICachedObject, ICachedObject, ICachedObject> iterator = new BaseHashMap <int, ICachedObject, ICachedObject, ICachedObject> .BaseHashIterator <int, ICachedObject, ICachedObject, ICachedObject>(this);

                int num3 = 0;
                while (iterator.HasNext())
                {
                    ICachedObject obj2 = iterator.Next();
                    if (iterator.GetAccessCount() <= accessCountCeiling)
                    {
                        lock (obj2)
                        {
                            if (obj2.IsKeepInMemory())
                            {
                                iterator.SetAccessCount(accessCountCeiling + 1);
                            }
                            else
                            {
                                obj2.SetInMemory(false);
                                if (obj2.HasChanged())
                                {
                                    this._rowTable[num3++] = obj2;
                                }
                                iterator.Remove();
                                this._cacheBytesLength -= obj2.GetStorageSize();
                                count--;
                            }
                        }
                    }
                    if (num3 == this._rowTable.Length)
                    {
                        this.SaveRows(num3);
                        num3 = 0;
                    }
                }
                base.SetAccessCountFloor(accessCountCeiling);
                this.SaveRows(num3);
            }
        }
Esempio n. 2
0
        public void ForceCleanUp()
        {
            lock (this)
            {
                BaseHashMap <int, ICachedObject, ICachedObject, ICachedObject> .BaseHashIterator <int, ICachedObject, ICachedObject, ICachedObject> iterator = new BaseHashMap <int, ICachedObject, ICachedObject, ICachedObject> .BaseHashIterator <int, ICachedObject, ICachedObject, ICachedObject>(this);

                while (iterator.HasNext())
                {
                    ICachedObject obj2 = iterator.Next();
                    lock (obj2)
                    {
                        if (!obj2.IsKeepInMemory())
                        {
                            obj2.SetInMemory(false);
                            iterator.Remove();
                            this._cacheBytesLength -= obj2.GetStorageSize();
                        }
                        continue;
                    }
                }
            }
        }