public void Stop()
 {
     if (Cache == null) return;
     try { if (_net != null) _net.Stop(); }
     catch { }
     _net = null;
     Cache.Dispose();
     Cache = null;
 }
 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 MemcachedProtocol(LocalCache cache, Connection dtc)
 {
     _cache = cache;
     _dtc = dtc;
     _data = dtc.Data;
 }