public void Start(bool console, string[] args) { //--load configuration from json file; var cjson = File.ReadAllText("cached.config"); Config = new CachedConfiguration(); Config.MergeFrom(cjson); //-- create instance of local cache and bind network listener to it. Cache = new LocalCache(Config); var uri = new Uri(Config.Address); switch (uri.Scheme) { case "tcp": _net = new SocketListener(); break; //--case "pipe": _net = new NamedPipeListener(); break; default: throw new ArgumentException("address:schema"); } _net.Start(uri, Cache.GetServiceProtocol); }
public LocalCache(CachedConfiguration config) { _config = config; _lock = new System.Threading.SpinLock(false); _tickTrac = Environment.TickCount; TimeOrigin = (uint)Pbs.DateToMsecs(DateTime.UtcNow); // init bitmasks for opcodes. QuietOps = new BitSet64(xGetQ, xSetQ, xGetKQ, xAddQ, xReplaceQ, xDeleteQ, xIncQ, xDecQ, xFlushQ, xAppendQ, xPrependQ, xQuitQ, xGatQ, xGatKQ); ReqsAdds = new BitSet64(xSet, xSetQ, xAdd, xAddQ, xAppend, xAppendQ, xPrepend, xPrependQ, xInc, xIncQ, xDec, xDecQ); ReqsSpecial = new BitSet64(xQuit, xQuitQ, xFlush, xVersion, xFlushQ, xStat, xNoop); RespWithExt = new BitSet64(xGet, xGetQ, xGetK, xGetKQ); RespWithKey = new BitSet64(xGetK, xGetKQ); IncDecOps = new BitSet64(xInc, xIncQ, xDec, xDecQ); // setup initial memory states. _virtual_memory = new WindowsVirtualMemory(config.UseLargePages); Stats.Init(config.CacheSize); ResetSlabs(); // calculate hash bits controls. _hashBits = 1; _hashMask = _config.HashTableSize - 1; for (var i = 1; i < _hashMask; i *= 2) _hashBits++; _hashBits -= 1; // sign for clock notifications. //todo:Clock.System.Append(OnClock, 1000); }