/// <summary> /// This function processes any file changes in the specified directory /// </summary> /// <param name="obj"></param> /// <returns></returns> protected object ProcessFileEvent(object obj) { string strFileName = (string)obj; IMemcachedDependancy objDependancy = null; // Lock the queue for processing lock (_objMemDepFileLock) { if (this._objMemDepFile.ContainsKey(strFileName) == true) { objDependancy = this._objMemDepFile[strFileName]; this._objMemDepFile.Remove(strFileName); Console.WriteLine("Item removed from Process Queue..."); } } if (objDependancy != null) { foreach (string str in objDependancy.DependancyKeys) { // Removing Key from memcached _objMemcachedClient.Remove(str); Console.WriteLine("Memcached Key {0} removed...", str); } } return(null); }
/// <summary> /// Processes client request /// </summary> /// <param name="obj">null</param> /// <returns>null</returns> protected object ProcessDependancyRequest(object obj) { #region Processing Request TcpClient objClient = (TcpClient)obj; NetworkStream objStream = objClient.GetStream(); string str = string.Empty; try { str = this.ReadLine(objStream); try { bool bResult = false; IMemcachedDependancy objDep = DependancyParser.ProcessCommand(str); if (objDep == null) { throw new Exception(); } if (objDep.Type == MemcachedDependancy.File) { lock (_objMemDepFileLock) { if (this._objMemDepFile.ContainsKey(objDep.KeyToIndex) == false) { this._objMemDepFile.Add(objDep.KeyToIndex, objDep); } else { this._objMemDepFile[objDep.KeyToIndex] = objDep; } bResult = true; } } #region Comments //else if(objDep.Type == MemcachedDependancy.OtherKey) //{ // lock (_objMemDepKeyLock) // { // if (this._objMemDepKey.ContainsKey(objDep.KeyToIndex) == false) // { // this._objMemDepKey.Add(objDep.KeyToIndex, objDep); // } // else // { // this._objMemDepKey[objDep.KeyToIndex] = objDep; // } // bResult = true; // } //} #endregion if (bResult == true) { SendSuccessMessage(objStream); } else { SendErrorMessage(objStream); } } catch (Exception err) { Console.WriteLine(err); SendErrorMessage(objStream); throw; } objStream.Flush(); Console.WriteLine(); Console.WriteLine("Putting the TCP client back in queue....."); lock (_objSocketLock) { this._objClientQueue.Enqueue(new PooledTcpClient(objClient, this._iCounterLimit)); } } catch (Exception err) { Console.WriteLine("Exception occured....connection closed: " + err); } #endregion return(null); }