示例#1
0
        private void btnGetValue_Click(object sender, EventArgs e)
        {
            string[] serverlist = { txtServer.Text };

            SockIOPool pool = SockIOPool.GetInstance();
            pool.SetServers(serverlist);

            pool.InitConnections = 3;
            pool.MinConnections = 3;
            pool.MaxConnections = 5;

            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout = 3000;

            pool.MaintenanceSleep = 30;
            pool.Failover = true;

            pool.Nagle = false;
            pool.Initialize();

            MemcachedClient mc = new MemcachedClient();
            mc.EnableCompression = false;

            string value = (string)mc.Get(txtKey.Text);
            MessageBox.Show(value);
        }
示例#2
0
        static void Main(string[] args)
        {
            //分布Memcachedf服务IP 端口
            string[] servers =
            {
                "192.168.1.105:11211"
            };

            //初始化池
            SockIOPool pool = SockIOPool.GetInstance();

            pool.SetServers(servers);
            pool.InitConnections      = 3;
            pool.MinConnections       = 3;
            pool.MaxConnections       = 5;
            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout        = 3000;
            pool.MaintenanceSleep     = 30;
            pool.Failover             = true;
            pool.Nagle = false;
            pool.Initialize();
            //客户端实例
            MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();

            mc.EnableCompression = false;

            string key1   = "key-1";
            string value1 = "value1";

            mc.Add(key1, value1);
            Console.WriteLine(key1 + "   " + mc.Get(key1));

            string key2   = "key5";
            string value2 = "value5";

            mc.Add(key2, value2);
            Console.WriteLine(key2 + "   " + mc.Get(key2));



            //var userInfos = UserInfoService.GetEntities(u => u.UName == "admin" && u.Pwd == "123456" && u.DelFlag == "0").FirstOrDefault();
            //var userinfo ={string username="******",string wd="123456"}
            mc.Add("d4491076-3a6b-4f47-9515-a2bb64e7869c", "11111");
            Console.WriteLine(mc.Get("d4491076-3a6b-4f47-9515-a2bb64e7869c"));
        }
示例#3
0
 private static void ReadData(MemcachedClient mc)
 {
     for (int i = 0; i < _loopFor; i++)
     {
         Thread.Sleep(1000);
         Console.WriteLine("Thread: " + Thread.CurrentThread.ManagedThreadId + " Contents of cache: " +
                             mc.Get("1") + " @ " + DateTime.Now);
     }
 }
示例#4
0
 /// <summary>
 /// 获取缓存内的键值
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="strKey"></param>
 /// <returns></returns>
 public static T GetCache <T>(string strKey)
 {
     if (MC.KeyExists(strKey) == true)
     {
         return(MC.Get <T>(strKey));
     }
     else
     {
         return(default(T));
     }
 }
        public override object Get(string key)
        {
            Debug.WriteLine("Get " + key);

            InicializaMemcached();

            MemcachedClient cache = new MemcachedClient();

            string chave = MD5(key);

            if (cache.KeyExists(chave))
            {
                return cache.Get(chave);
            }
            else
            {
                return null;
            }
        }
示例#6
0
    public static string fn_MemGet(string key)
    {
        SockIOPool pool = SockIOPool.GetInstance("test");
        pool.SetServers(serverlist);
        pool.Initialize();

        MemcachedClient mc = new MemcachedClient();
        mc.PoolName = "test";
        mc.EnableCompression = false;

        string values = null;
        try
        {
            values = (string)mc.Get(key);
        }
        catch (System.Exception e)
        {
        }
        return values;
    }
示例#7
0
        static void Main(string[] args)
        {
            //分布Memcached服务IP:端口
            //string[] servers = { "192.168.1.113:11211", "192.168.202.128:11211" };
            string[] servers = { "127.0.0.1:11211" };
            //初始化池。通俗说pool就是与mm服务器端交换数据的对象,通过它设置连接mm服务器端相关属性
            SockIOPool pool = SockIOPool.GetInstance();

            //设置服务器列表
            pool.SetServers(servers);
            //初始化时创建连接数
            pool.InitConnections = 3;
            //最小连接数
            pool.MinConnections = 3;
            //最大连接数
            pool.MaxConnections = 5;
            //socket连接的超时时间,如果为0表示不超时(单位ms),即一直保持链接状态
            pool.SocketConnectTimeout = 1000;
            //通讯的超时时间,下面设置为3秒(单位ms),
            pool.SocketTimeout = 3000;
            //维护线程的间隔激活时间,下面设置为30秒(单位s),设置为0时表示不启用维护线程
            pool.MaintenanceSleep = 30;
            //设置SocktIO池的故障标志
            pool.Failover = true;
            //是否对TCP/IP通讯使用nalgle算法,
            pool.Nagle = false;
            pool.Initialize();
            //客户端实例
            MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();

            //是否启用压缩数据:如果启用了压缩,数据压缩长于门槛的数据将被以压缩的形式存储
            mc.EnableCompression = false;
            //mc.Add("keyxdz", "1ssss");//这个时候数据存储到哪里去了呢(某一台机器缓存)?根据mm客户端集群原理可理解
            //mc.Set("keyxdz3", "2ssss", DateTime.Now.AddDays(1));//表示有效期为1天

            mc.Delete("keyxdz3");//删除键为keyxdz的值,之后通过MM的命令提示符窗口也不到key为keyxdz的值了
            string s = mc.Get("keyxdz3").ToString();

            Console.WriteLine(s);//输出2ssss
        }
        public override object Add(string key, object entry, DateTime utcExpiry)
        {
            utcExpiry = TimeZoneInfo.ConvertTimeFromUtc(utcExpiry, TimeZoneInfo.Local);
            var agora = DateTime.Now;
            Debug.WriteLine("Add"+key + " __ " + utcExpiry.Subtract(agora).TotalSeconds.ToString());

            InicializaMemcached();

            MemcachedClient cache = new MemcachedClient();

            string chave = MD5(key);

            if (cache.KeyExists(chave))
            {
                return cache.Get(chave);
            }
            else
            {
                cache.Set(chave, entry, utcExpiry.ToUniversalTime());
                return entry;
            }
        }
示例#9
0
        public void test()
        {
            //分布Memcachedf服务IP 端口
            string[] servers = { "127.0.0.1:11211" };

            //初始化池
            SockIOPool pool = SockIOPool.GetInstance();

            pool.SetServers(servers, true);
            pool.InitConnections      = 3;
            pool.MinConnections       = 3;
            pool.MaxConnections       = 5;
            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout        = 3000;
            pool.MaintenanceSleep     = 30;
            pool.Failover             = true;
            pool.Nagle = false;
            pool.Initialize();
            //客户端实例
            MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();

            mc.EnableCompression = false;
            StringBuilder sb = new StringBuilder();

            //写入缓存
            sb.AppendLine("写入缓存测试:");
            sb.AppendLine("<br>_______________________________________<br>");
            if (mc.KeyExists("cache"))
            {
                sb.AppendLine("缓存cache已存在");
            }
            else
            {
                mc.Set("cache", "写入缓存时间:" + DateTime.Now.ToString());
                sb.AppendLine("缓存已成功写入到cache");
            }

            sb.AppendLine("<br>_______________________________________<br>");
            sb.AppendLine("读取缓存内容如下:<br>");
            sb.AppendLine(mc.Get("cache").ToString());

            //测试缓存过期
            sb.AppendLine("<br>_______________________________________<br>");
            if (mc.KeyExists("endCache"))
            {
                sb.AppendLine("缓存endCache已存在,过期时间为:" + mc.Get("endCache").ToString());
            }
            else
            {
                mc.Set("endCache", DateTime.Now.AddMinutes(1).ToString(), DateTime.Now.AddMinutes(1));
                sb.AppendLine("缓存已更新写入到endCache,写入时间:" + DateTime.Now.ToString() + " 过期时间:" + DateTime.Now.AddMinutes(1).ToString());
            }

            //分析缓存状态
            Hashtable ht = mc.Stats();

            sb.AppendLine("<br>_______________________________________<br>");
            sb.AppendLine("Memcached Stats:");
            sb.AppendLine("<br>_______________________________________<br>");
            foreach (DictionaryEntry de in ht)
            {
                Hashtable info = (Hashtable)de.Value;
                foreach (DictionaryEntry de2 in info)
                {
                    sb.AppendLine(de2.Key.ToString() + ":&nbsp;&nbsp;&nbsp;&nbsp;" + de2.Value.ToString() + "<br>");
                }
            }
            Console.WriteLine(sb.ToString());
            //Response.Write(sb.ToString());
        }
示例#10
0
        public static void Main(String[] args)
        {
            int runs = 100;
            int start = 200;
            if(args.Length > 1)
            {
                runs = int.Parse(args[0]);
                start = int.Parse(args[1]);
            }

            string[] serverlist = { "192.168.111.16:11211", "192.168.111.152:11211" };

            // initialize the pool for memcache servers
            SockIOPool pool = SockIOPool.GetInstance();
            pool.SetServers(serverlist);

            pool.InitConnections = 3;
            pool.MinConnections = 3;
            pool.MaxConnections = 5;

            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout = 3000;

            pool.MaintenanceSleep = 30;
            pool.Failover = true;

            pool.Nagle = false;
            pool.Initialize();

            // initialize the pool for memcache servers
            //			SockIOPool pool = SockIOPool.Instance;
            //			pool.Servers = serverlist;
            //
            //			pool.InitConn = 5;
            //			pool.MinConn = 5;
            //			pool.MaxConn = 50;
            //			pool.MaintSleep = 30;
            //			pool.SocketTO = 1000;
            //
            //			pool.Nagle = false;
            //			pool.Initialize();

            //
            //			// get client instance
            MemcachedClient mc = new MemcachedClient();
            mc.EnableCompression = false;

            //			MemcachedClient mc = new MemcachedClient();
            //			mc.CompressEnable = false;
            //			mc.CompressThreshold = 0;
            //			mc.Serialize = true;

            string keyBase = "testKey";
            string obj = "This is a test of an object blah blah es, serialization does not seem to slow things down so much.  The gzip compression is horrible horrible performance, so we only use it for very large objects.  I have not done any heavy benchmarking recently";

            long begin = DateTime.Now.Ticks;
            for(int i = start; i < start+runs; i++)
            {
                mc.Set(keyBase + i, obj);
            }
            long end = DateTime.Now.Ticks;
            long time = end - begin;

            Console.WriteLine(runs + " sets: " + new TimeSpan(time).ToString() + "ms");

            begin = DateTime.Now.Ticks;
            int hits = 0;
            int misses = 0;
            for(int i = start; i < start+runs; i++)
            {
                string str = (string) mc.Get(keyBase + i);
                if(str != null)
                    ++hits;
                else
                    ++misses;
            }
            end = DateTime.Now.Ticks;
            time = end - begin;

            Console.WriteLine(runs + " gets: " + new TimeSpan(time).ToString() + "ms");
            Console.WriteLine("Cache hits: " + hits.ToString());
            Console.WriteLine("Cache misses: " + misses.ToString());

            IDictionary stats = mc.Stats();
            foreach(string key1 in stats.Keys)
            {
                Console.WriteLine(key1);
                Hashtable values = (Hashtable)stats[key1];
                foreach(string key2 in values.Keys)
                {
                    Console.WriteLine(key2 + ":" + values[key2]);
                }
                Console.WriteLine();
            }

            SockIOPool.GetInstance().Shutdown();
        }
示例#11
0
        public void test()
        {
            //分布Memcachedf服务IP 端口
            string[] servers = { "192.168.3.33:11211", "192.168.202.128:11211" };

            //初始化池
            SockIOPool pool = SockIOPool.GetInstance();
            pool.SetServers(servers);
            pool.InitConnections = 3;
            pool.MinConnections = 3;
            pool.MaxConnections = 5;
            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout = 3000;
            pool.MaintenanceSleep = 30;
            pool.Failover = true;
            pool.Nagle = false;
            pool.Initialize();
            //客户端实例
            MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();
            mc.EnableCompression = false;
            StringBuilder sb = new StringBuilder();
            //写入缓存
            sb.AppendLine("写入缓存测试:");
            sb.AppendLine("<br>_______________________________________<br>");
            if (mc.KeyExists("cache"))
            {
                sb.AppendLine("缓存cache已存在");
            }
            else
            {
                mc.Set("cache", "写入缓存时间:" + DateTime.Now.ToString());
                sb.AppendLine("缓存已成功写入到cache");
            }
            sb.AppendLine("<br>_______________________________________<br>");
            sb.AppendLine("读取缓存内容如下:<br>");
            sb.AppendLine(mc.Get("cache").ToString());

            //测试缓存过期
            sb.AppendLine("<br>_______________________________________<br>");
            if (mc.KeyExists("endCache"))
            {
                sb.AppendLine("缓存endCache已存在,过期时间为:" + mc.Get("endCache").ToString());
            }
            else
            {
                mc.Set("endCache", DateTime.Now.AddMinutes(1).ToString(), DateTime.Now.AddMinutes(1));
                sb.AppendLine("缓存已更新写入到endCache,写入时间:" + DateTime.Now.ToString() + " 过期时间:" + DateTime.Now.AddMinutes(1).ToString());
            }

            //分析缓存状态
            Hashtable ht = mc.Stats();
            sb.AppendLine("<br>_______________________________________<br>");
            sb.AppendLine("Memcached Stats:");
            sb.AppendLine("<br>_______________________________________<br>");
            foreach (DictionaryEntry de in ht)
            {
                Hashtable info = (Hashtable)de.Value;
                foreach (DictionaryEntry de2 in info)
                {
                    sb.AppendLine(de2.Key.ToString() + ":&nbsp;&nbsp;&nbsp;&nbsp;" + de2.Value.ToString() + "<br>");
                }
            }
            Response.Write(sb.ToString());
        }
示例#12
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            FileInfo fileInfo = new FileInfo(context.Request.MapPath(context.Request.CurrentExecutionFilePath));
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = false;
            m_context = context;
            m_httpMethod = m_context.Request.HttpMethod;
            m_memcachedClient = (Client)context.Application["memcached"];
            m_queueClient = (QueueClient)context.Application["queueclient"];
            m_xslTransformationManager = (XsltTransformationManager)context.Application["xslTransformationManager"];
            m_transform = m_xslTransformationManager.Transform;
            m_xsltParams = (Hashtable)context.Application["globalXsltParams"];
            m_namedXsltHashtable = (Hashtable)context.Application["namedXsltHashtable"];
            m_transformContext = new Transform.Context(context, m_hashAlgorithm, (string)context.Application["hashkey"], fileInfo, (Hashtable)m_xsltParams.Clone(), fileInfo.LastWriteTimeUtc, fileInfo.Length);
            m_transformAsyncResult = new NuxleusAsyncResult(cb, extraData);
            m_callback = cb;
            m_transformAsyncResult.m_context = context;
            m_builder = new StringBuilder();
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = (bool)context.Application["usememcached"];

            bool hasXmlSourceChanged = m_xslTransformationManager.HasXmlSourceChanged(m_transformContext.RequestXmlETag);
            bool hasBaseXsltSourceChanged = m_xslTransformationManager.HasBaseXsltSourceChanged();

            if (m_USE_MEMCACHED)
            {

                string obj = (string)m_memcachedClient.Get(m_transformContext.GetRequestHashcode(true));

                if (obj != null && !(hasXmlSourceChanged || hasBaseXsltSourceChanged) && !(m_context.Request.CurrentExecutionFilePath.StartsWith("/service/session")  && !(m_context.Request.CurrentExecutionFilePath.StartsWith("/service/geo"))))
                {
                    m_builder.Append(obj);
                    m_CONTENT_IS_MEMCACHED = true;
                    if ((bool)context.Application["debug"])
                        context.Response.ContentType = "text";
                    else
                        context.Response.ContentType = "text/xml";
                }
                else
                {
                    m_writer = new StringWriter(m_builder);
                    m_CONTENT_IS_MEMCACHED = false;
                }
            }
            else
            {
                m_writer = new StringWriter(m_builder);
            }

            //if ((bool)context.Application["debug"])
            //{
            //    context.Response.Write("<debug>");
            //    context.Response.Write("<file-info>");
            //    context.Response.Write("Has Xml Changed: " + hasXmlSourceChanged + ":" + m_transformContext.RequestXmlETag + "<br/>");
            //    context.Response.Write("Has Xslt Changed: " + hasBaseXsltSourceChanged + "<br/>");
            //    context.Response.Write("Xml ETag: " + m_transformContext.GetRequestHashcode(true) + "<br/>");
            //    context.Response.Write("XdmNode Count: " + m_xslTransformationManager.GetXdmNodeHashtableCount() + "<br/>");
            //    context.Response.Write("</file-info>");
            //    context.Application["debugOutput"] = (string)("<DebugOutput>" + WriteDebugOutput(m_transformContext, m_xslTransformationManager, new StringBuilder(), m_CONTENT_IS_MEMCACHED).ToString() + "</DebugOutput>");
            //    context.Response.Write("</debug>");
            //}

            try
            {

                switch (m_httpMethod)
                {
                    case "GET":
                    case "HEAD":
                        {
                            if (m_CONTENT_IS_MEMCACHED)
                            {
                                m_transformAsyncResult.CompleteCall();
                                return m_transformAsyncResult;
                            }
                            else
                            {
                                try
                                {
                                    string file = m_context.Request.FilePath;
                                    string baseXslt;

                                    if (file.EndsWith("index.page"))
                                    {
                                        baseXslt = "precompile-atomictalk";
                                    }
                                    else if (file.EndsWith("service.op"))
                                        baseXslt = "base";
                                    else
                                        baseXslt = m_xslTransformationManager.BaseXsltName;

                                    //m_transform.BeginTransformProcess(m_transformContext, context, m_xslTransformationManager, m_writer, baseXslt, m_transformAsyncResult);
                                    return m_transformAsyncResult;
                                }
                                catch (Exception e)
                                {
                                    m_exception = e;
                                    WriteError();
                                    m_transformAsyncResult.CompleteCall();
                                    return m_transformAsyncResult;
                                }
                            }
                        }
                    case "PUT":
                        {
                            
                            return m_transformAsyncResult;
                        }
                    case "POST":
                        {
                            return m_transformAsyncResult;
                        }
                    case "DELETE":
                        {
                            return m_transformAsyncResult;
                        }
                    default:
                        {
                            return m_transformAsyncResult;
                        }
                }

            }
            catch (Exception ex)
            {
                m_exception = ex;
                WriteError();
                m_transformAsyncResult.CompleteCall();
                return m_transformAsyncResult;
            }
        }
示例#13
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            FileInfo fileInfo = new FileInfo(context.Request.MapPath(context.Request.CurrentExecutionFilePath));

            _context = context;
            _httpMethod = _context.Request.HttpMethod;
            _memcachedClient = (Client)context.Application["memcached"];
            _xslTransformationManager = (XsltTransformationManager)context.Application["xslTransformationManager"];
            _transform = _xslTransformationManager.Transform;
            _xsltParams = (Hashtable)context.Application["globalXsltParams"];
            _namedXsltHashtable = (Hashtable)context.Application["namedXsltHashtable"];
            _transformContext = new Context(context, _hashAlgorithm, (string)context.Application["hashkey"], fileInfo, (Hashtable)_xsltParams.Clone(), fileInfo.LastWriteTimeUtc, fileInfo.Length);
            _transformAsyncResult = new TransformServiceAsyncResult(cb, extraData);
            _callback = cb;
            _transformAsyncResult._context = context;
            _builder = new StringBuilder();
            _CONTENT_IS_MEMCACHED = false;
            _USE_MEMCACHED = (bool)context.Application["usememcached"];

            bool hasXmlSourceChanged = _xslTransformationManager.HasXmlSourceChanged(_transformContext.RequestXmlETag);
            bool hasBaseXsltSourceChanged = _xslTransformationManager.HasBaseXsltSourceChanged();

            if (_USE_MEMCACHED)
            {
                string obj = (string)_memcachedClient.Get(_transformContext.GetRequestHashcode(true));
                if (obj != null && !(hasXmlSourceChanged || hasBaseXsltSourceChanged))
                {
                    _builder.Append(obj);
                    _CONTENT_IS_MEMCACHED = true;
                    if ((bool)context.Application["debug"])
                        context.Response.ContentType = "text";
                    else
                        context.Response.ContentType = "text/xml";
                }
                else
                {
                    _writer = new StringWriter(_builder);
                    _CONTENT_IS_MEMCACHED = false;
                }
            }
            else
            {
                _writer = new StringWriter(_builder);
            }

            if ((bool)context.Application["debug"])
            {
                context.Response.Write("<debug>");
                context.Response.Write("<file-info>");
                context.Response.Write("Has Xml Changed: " + hasXmlSourceChanged + ":" + _transformContext.RequestXmlETag + "<br/>");
                context.Response.Write("Has Xslt Changed: " + hasBaseXsltSourceChanged + "<br/>");
                context.Response.Write("Xml ETag: " + _transformContext.GetRequestHashcode(true) + "<br/>");
                context.Response.Write("XdmNode Count: " + _xslTransformationManager.GetXdmNodeHashtableCount() + "<br/>");
                context.Response.Write("</file-info>");
                context.Application["debugOutput"] = (string)("<DebugOutput>" + WriteDebugOutput(_transformContext, _xslTransformationManager, new StringBuilder(), _CONTENT_IS_MEMCACHED).ToString() + "</DebugOutput>");
                context.Response.Write("</debug>");
            }

            try
            {

                switch (_httpMethod)
                {
                    case "GET":
                        {
                            if (_CONTENT_IS_MEMCACHED)
                            {
                                _transformAsyncResult.CompleteCall();
                                return _transformAsyncResult;
                            }
                            else
                            {
                                try
                                {
                                    _transform.BeginProcess(_transformContext, context, _xslTransformationManager, _writer, _transformAsyncResult);
                                    return _transformAsyncResult;
                                }
                                catch (Exception e)
                                {
                                    _exception = e;
                                    WriteError();
                                    _transformAsyncResult.CompleteCall();
                                    return _transformAsyncResult;
                                }
                            }
                        }
                    case "PUT":
                        {
                            _transform.BeginProcess(_transformContext, context, _xslTransformationManager, _writer, _transformAsyncResult);
                            return _transformAsyncResult;
                        }
                    case "POST":
                        {
                            _transform.BeginProcess(_transformContext, context, _xslTransformationManager, _writer, _transformAsyncResult);
                            return _transformAsyncResult;
                        }
                    case "DELETE":
                        {
                            _transform.BeginProcess(_transformContext, context, _xslTransformationManager, _writer, _transformAsyncResult);
                            return _transformAsyncResult;
                        }
                    default:
                        {
                            _transform.BeginProcess(_transformContext, context, _xslTransformationManager, _writer, _transformAsyncResult);
                            return _transformAsyncResult;
                        }
                }

            }
            catch (Exception ex)
            {
                _exception = ex;
                WriteError();
                _transformAsyncResult.CompleteCall();
                return _transformAsyncResult;
            }
        }
        public void VerifyTheWholeLifecycleOfARunningPool()
        {
            StartPool();
            Assert.IsTrue(pool.IsRunning);

            MemcachedClient client = new MemcachedClient();
            client.PoolName = pool.PoolName;
            client.Set("key", "value");
            Assert.AreEqual("value", client.Get("key"));

            pool.Stop();
            Assert.IsFalse(pool.IsRunning);
        }
示例#15
0
 public static object Set(string key)
 {
     return(mc.Get(key));
 }
示例#16
0
 private static void WriteData(MemcachedClient mc)
 {
     for (int i = 0; i < _loopFor; i++)
     {
         Thread.Sleep(1000);
         if (mc.Get("1") == null)
             mc.Set("1", DateTime.Now, DateTime.Now.AddSeconds(10));
     }
 }
        public IAsyncResult BeginProcessRequest ( HttpContext context, AsyncCallback cb, object extraData ) {

            m_stopwatch.Start();

            FileInfo fileInfo = new FileInfo(context.Request.MapPath(context.Request.CurrentExecutionFilePath));
            this.LogDebug("File Date: {0}; File Length: {1}", fileInfo.LastWriteTimeUtc, fileInfo.Length);
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = false;
            m_httpContext = context;
            m_returnOutput = true;
            m_httpMethod = m_httpContext.Request.HttpMethod;
            m_memcachedClient = (Client)context.Application["memcached"];
            m_encoding = (UTF8Encoding)context.Application["encoding"];
            m_queueClient = (QueueClient)context.Application["queueclient"];
            m_hashkey = (string)context.Application["hashkey"];
            m_xmlServiceOperationManager = (XPathServiceOperationManager)context.Application["xmlServiceOperationManager"];
            m_xslTransformationManager = (XsltTransformationManager)context.Application["xslTransformationManager"];
            m_transform = m_xslTransformationManager.Transform;
            m_xsltParams = (Hashtable)context.Application["globalXsltParams"];
            m_transformContext = new Transform.Context(context, m_hashAlgorithm, (string)context.Application["hashkey"], fileInfo, (Hashtable)m_xsltParams.Clone(), fileInfo.LastWriteTimeUtc, fileInfo.Length);
            m_namedXsltHashtable = (Hashtable)context.Application["namedXsltHashtable"];
            m_xmlSourceETagDictionary = m_xmlServiceOperationManager.XmlSourceETagDictionary;
            m_xmlReaderDictionary = m_xmlServiceOperationManager.XmlReaderDictionary;
            m_context = new Context(context, m_hashAlgorithm, m_hashkey, fileInfo, fileInfo.LastWriteTimeUtc, fileInfo.Length);
            this.LogDebug("File Date: {0}; File Length: {1}", m_context.RequestXmlFileInfo.LastWriteTimeUtc, m_context.RequestXmlFileInfo.Length);
            m_nuxleusAsyncResult = new Nuxleus.Core.NuxleusAsyncResult(cb, extraData);
            m_callback = cb;
            m_nuxleusAsyncResult.m_context = context;
            m_builder = new StringBuilder();
            m_CONTENT_IS_MEMCACHED = false;
            m_USE_MEMCACHED = (bool)context.Application["usememcached"];
            Uri requestUri = new Uri(m_context.RequestUri);
            m_requestHashcode = m_context.GetRequestHashcode(true).ToString();
            m_lastModifiedKey = String.Format("LastModified:{0}", m_context.RequestUri.GetHashCode());
            m_lastModifiedDate = String.Empty;
            m_request = new TransformRequest();
            m_response = new TransformResponse();
            Guid requestGuid = Guid.NewGuid();
            m_request.ID = requestGuid;

            
            context.Response.ContentType = "text/xml";

            IEnumerator headers = context.Request.Headers.GetEnumerator();
            for (int i = 0; headers.MoveNext(); i++) {
                string local = context.Request.Headers.AllKeys[i].ToString();
                this.LogDebug("KeyName: {0}, KeyValue: {1}", local, context.Request.Headers[local]);
            }
            bool hasXmlSourceChanged = m_xmlServiceOperationManager.HasXmlSourceChanged(m_context.RequestXmlETag, requestUri);

            //if (m_USE_MEMCACHED) {

            //    string obj = (string)m_memcachedClient.Get(m_context.GetRequestHashcode(true).ToString());

            //    if (obj != null && !hasXmlSourceChanged) {
            //        m_response.TransformResult = (string)obj;
            //        m_CONTENT_IS_MEMCACHED = true;
            //        if ((bool)context.Application["debug"]) {
            //            context.Response.ContentType = "text";
            //        }
            //    } else {
            //        //m_writer = new StringWriter(m_builder);
            //        m_CONTENT_IS_MEMCACHED = false;
            //    }
            //} else {
            //    m_writer = new StringWriter(m_builder);
            //}

            m_writer = new StringWriter(m_builder);

            try {

                switch (m_httpMethod) {
                    case "GET":
                    case "HEAD":
                    case "POST": {                     
                            string name = String.Format("Name: {0}", context.Request.QueryString["name"]);
                            this.LogDebug("QueryString Length: {0}", context.Request.QueryString.Count);
                            this.LogDebug(name);
                            this.LogDebug("If-None-Match: {0}, RequestHashCode: {1}", context.Request.Headers["If-None-Match"], m_requestHashcode);
                            this.LogDebug(context.Request.Path);
                            if (context.Request.Headers["If-None-Match"] == m_requestHashcode) {
                                this.LogDebug("They matched.");
                                this.LogDebug("Use memcached: {0}, KeyExists: {1}, XmlSource Changed: {2}", m_USE_MEMCACHED, m_memcachedClient.KeyExists(m_lastModifiedKey), hasXmlSourceChanged);
                                this.LogDebug("Last Modified Key Value: {0}", m_lastModifiedKey);
                                if (m_USE_MEMCACHED && m_memcachedClient.KeyExists(m_lastModifiedKey) && !hasXmlSourceChanged) {
                                    m_lastModifiedDate = (string)m_memcachedClient.Get(m_lastModifiedKey);
                                    this.LogDebug("Last Modified Date: {0}", m_lastModifiedDate);
                                    if (context.Request.Headers["If-Modified-Since"] == m_lastModifiedDate) {

                                        context.Response.StatusCode = 304;
                                        m_returnOutput = false;
                                        goto CompleteCall;
                                    } else {
                                        goto Process;
                                    }
                                } else if (m_CONTENT_IS_MEMCACHED) {
                                    goto CompleteCall;
                                } else {
                                    goto Process;
                                }
                            } else {
                                this.LogDebug("Headers do not match.  Beginning transformation process...");
                                m_returnOutput = true;
                                goto Process;
                            }
                        }
                    case "PUT": {
                            goto CompleteCall;
                        }
                    case "DELETE": {
                            goto CompleteCall;
                        }
                    default: {
                            goto CompleteCall;
                        }
                }

            } catch (Exception ex) {
                m_exception = ex;
                WriteError();
                goto CompleteCall;
            }
        Process:
            try {
                this.LogDebug("Processing Transformation");
                this.LogDebug("Request XML ETag Value: {0}, Request URI: {1}", m_context.RequestXmlETag, requestUri);

                XPathNavigator navigator = m_xmlServiceOperationManager.GetXPathNavigator(m_context.RequestXmlETag, requestUri);
                //if (initialReader == null) {
                //    initialReader = reader;
                //} else {
                //    this.LogDebug("XmlReaders are the same object: {0}", initialReader.Equals(reader));
                //}
                //this.LogDebug("XML Reader Value: {0}", reader.ReadOuterXml());
                //this.LogDebug("XML Reader Hash: {0}", reader.GetHashCode());
                XPathServiceOperationNavigator serviceOperationReader = new XPathServiceOperationNavigator(context, m_context, m_transformContext, navigator, m_request, m_response, m_xslTransformationManager);
                m_response = serviceOperationReader.Process();

            } catch (Exception e) {
                this.LogDebug("Error: {0} in transformation.", e.Message);
                m_exception = e;
                WriteError();
            }

            goto CompleteCall;

        CompleteCall:
            this.LogDebug("CompleteCall reached");
            if (m_lastModifiedDate == String.Empty) {
                m_lastModifiedDate = DateTime.UtcNow.ToString("r");
            }
            context.Response.AppendHeader("Cache-Control", "max-age=86400");
            context.Response.AddHeader("Last-Modified", m_lastModifiedDate);
            context.Response.AddHeader("ETag", String.Format("\"{0}\"", m_requestHashcode));
            m_nuxleusAsyncResult.CompleteCall();
            return m_nuxleusAsyncResult;
        }