예제 #1
0
        private KeyValueMemory(KeyValueMemoryConfiguration configuration, ILoggerFactory loggerFactory = null)
        {
            this.configuration = configuration;
            loggerFactory ??= DeltaX.Configuration.Configuration.DefaultLoggerFactory;
            this.logger = loggerFactory.CreateLogger($"KVM_{configuration.MemoryName}");

            string indexName = $"{configuration.MemoryName}.index";
            string dataName  = $"{configuration.MemoryName}.data";

            keys    = new ConcurrentDictionary <string, int>();
            mmIndex = new MemoryMappedRecord(indexName, configuration.IndexCapacity, configuration.Persistent, logger);
            mmData  = new MemoryMappedRecord(dataName, configuration.DataCapacity, configuration.Persistent, logger);

            InitializeKeys();
        }
예제 #2
0
        public static IKeyValueMemory Build(
            string memoryName,
            int indexCapacity            = 0,
            int dataCapacity             = 0,
            bool persistent              = true,
            ILoggerFactory loggerFactory = null)
        {
            var configuration = new KeyValueMemoryConfiguration
            {
                MemoryName    = memoryName,
                IndexCapacity = indexCapacity,
                DataCapacity  = dataCapacity,
                Persistent    = persistent
            };

            return(new KeyValueMemory(configuration, loggerFactory));
        }
예제 #3
0
 public static IKeyValueMemory Build(
     KeyValueMemoryConfiguration configuration,
     ILoggerFactory loggerFactory = null)
 {
     return(new KeyValueMemory(configuration, loggerFactory));
 }