Ejemplo n.º 1
0
        public const int REC_PER_PAGE_DEFAULT = 7;       //must be prime
        #endregion


        #region .ctor


        internal Table(CacheStore store, string name, TableOptions opt)
        {
            var bucketCount = opt != null ? opt.BucketCount : 0;
            var recPerPage  = opt != null ? opt.RecPerPage  : 0;
            var lockCount   = opt != null ? opt.LockCount   : 0;

            if (opt != null)
            {
                MaxAgeSec     = opt.MaxAgeSec;
                ParallelSweep = opt.ParallelSweep;
            }


            Debug.Assert(store != null);
            Debug.Assert(name != null);

            if (bucketCount <= 0)
            {
                bucketCount = BUCKET_COUNT_DEFAULT;
            }
            if (recPerPage <= 0)
            {
                recPerPage = REC_PER_PAGE_DEFAULT;
            }

            if (bucketCount == recPerPage)
            {
                recPerPage += 7;    //prime
                store.WriteLog(Log.MessageType.Warning, nameof(Table),
                               StringConsts.CACHE_TABLE_CTOR_SIZES_WARNING,
                               pars: "Table: {0} BucketCount: {1} RecPerPage: {2}".Args(name, bucketCount, recPerPage));
            }

            m_Store       = store;
            m_Name        = name;
            m_BucketCount = bucketCount;
            m_RecPerPage  = recPerPage;
            m_Buckets     = new Bucketed[m_BucketCount];

            m_LockCount = lockCount > 0 ? lockCount : System.Environment.ProcessorCount * 16;
            m_Locks     = new object[m_LockCount];
            for (var i = 0; i < m_LockCount; i++)
            {
                m_Locks[i] = new object();
            }
        }
Ejemplo n.º 2
0
 public ComplexKeyHashingStrategy(CacheStore store)
 {
     Store = store;
 }