Ejemplo n.º 1
0
        public Present Get(IFuture future, string refCredit)
        {
            string text  = this.makeCachePathname(future, "fresh.");
            string text2 = this.makeCachePathname(future, "stale.");

            Monitor.Enter(this);
            try
            {
                long    num;
                Present present = this.Fetch(text, out num);
                if (present != null)
                {
                    D.Sayf(10, "fresh hit! {0}", new object[]
                    {
                        "fresh."
                    });
                    Present result = present;
                    return(result);
                }
                present = this.Fetch(text2, out num);
                if (present != null)
                {
                    File.Move(text2, text);
                    this.IncrementFreshCount(num);
                    D.Sayf(10, "stale hit! {0} {1}", new object[]
                    {
                        "stale.",
                        num
                    });
                    Present result = present;
                    return(result);
                }
            }
            finally
            {
                Monitor.Exit(this);
            }
            Present result2 = future.Realize(refCredit);

            this.ScheduleDeferredWrite(result2, text, future.ToString());
            D.Sayf(10, "miss", new object[0]);
            return(result2);
        }
Ejemplo n.º 2
0
		public Present Get(IFuture future, string refCredit)
		{
			string text = this.makeCachePathname(future, "fresh.");
			string text2 = this.makeCachePathname(future, "stale.");
			Monitor.Enter(this);
			try
			{
				long num;
				Present present = this.Fetch(text, out num);
				if (present != null)
				{
					D.Sayf(10, "fresh hit! {0}", new object[]
					{
						"fresh."
					});
					Present result = present;
					return result;
				}
				present = this.Fetch(text2, out num);
				if (present != null)
				{
					File.Move(text2, text);
					this.IncrementFreshCount(num);
					D.Sayf(10, "stale hit! {0} {1}", new object[]
					{
						"stale.",
						num
					});
					Present result = present;
					return result;
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
			Present result2 = future.Realize(refCredit);
			this.ScheduleDeferredWrite(result2, text, future.ToString());
			D.Sayf(10, "miss", new object[0]);
			return result2;
		}