CodeCanyon CacheFabric 3895224

CodeCanyon CacheFabric 3895224

CodeCanyon CacheFabric 3895224
.NET Script \ Miscellaneous
Caching \ Cache \ Server \ Library \ Enterprise \ Sharp \ Data \ Performance \ Single



.NET Script - CacheFabric 3895224 by AvantPrime @ CodeCanyon

.NET Script \ Miscellaneous

Last Update: 27 January 13; Compatible Browsers: IE6, IE7, IE8, IE9, IE10, Firefox, Safari, Opera, Chrome; Software Version: .NET 3.5, .NET 3.7, .NET 4.0, .NET 4.5; Files Included: C# CS.

What is caching?

When working with computers a cache as defined by wikipedia “is a component that transparently stores data so that future requests for that data can be served faster”.

How can caching help?

The ever increasing need for applications to do more work and perform even faster is the main driving force for caching. Today’s users are accustomed to getting a response as soon as they press the button and caching plays an important role in fulfilling the users’ expectation.

Here are some of the benefits of caching.

- Reduce load on Web Services / Database – Great for increasing the number of users your application can handle simultaneously (Scale).

- Increase Performance – Meet yours users needs in functionality and application responsiveness.

- Reliability – Failing components could be masked by the cache while repairs/restarts are done.

- It greatly reduces overhead from server resources.

- Reserve server capacity for non-cacheable content and other operations.

- Achieve capital expenditure and operational savings by optimizing server utilization.

- Reduce content delivery times by serving content from fast memory cache storage.

What is CacheFabric?

Cache fabric is a powerful and easy to use component that brings the power of caching to your .NET applications. CacheFabric can be used in all .NET applications by simply selecting the appropriate caching mechanism to use. All the various caching mechanisms are built on the same foundation therefore there will never be a need to change your code, just simply change the cache component and you can switch from ASP.NET Cache to Enterprise Caching for a Single Server to AppFabric Server Distributed Caching .

The mechanisms for caching are.

- ASP.NET Cache – ASP.NET has a powerful, easy-to-use caching mechanism that allows you to store objects in memory that require extensive server resources to create. Caching these types of resources can significantly improve the performance of your application. Only to be used in web applications.

- Enterprise Library Cache – The Enterprise Library Caching Application Block lets developers incorporate a local cache in their applications. It supports both an in-memory cache and, optionally, a backing store that can either be the database store or isolated storage. The application block can be used without modification; it provides all the functionality needed to retrieve, add, and remove cached data. Configurable expiration and scavenging policies are also part of the application block. Can be used in all .NET applications.

- AppFabric Cache – Microsoft AppFabric 1.1 for Windows Server is a set of integrated technologies that makes it easier to build, scale, and manage Web and composite applications that run on IIS. Can be used in all .NET applications.

- NULL Caching – Stop caching without changing your code. Can be used in all .NET applications.

How do I use CacheFabric?

To use the cache factory simple create an ICacheDirector object and
use the methods Add , Get , etc to get access to the
caching operations. The available ICacheDirectors are: AppFabricCache, EnterpriseLibraryCache, AspNetCache and NullCache.

The following sample demonstrates the difference in performance when using a cache to retrieve previously processed data. The application loads a web page, stores it in the cache and then reloads it from the cache while monitoring the time it takes to perform all the operations.

using System;
using System.Diagnostics;
using System.Net;
using AvantPrime.Framework.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching;
namespace AvantPrime.CacheFabric.TestConsole
{
class Program
{
static readonly ICacheManager CacheManager = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager();
static readonly ICacheDirector Cache = new SingleServerCaching(CacheManager);
static void Main(string[] args)
{
var stopwatch = new Stopwatch();
var website = "http://www.microsoft.com";
stopwatch.Start();
Console.WriteLine("Warmup Run");
LoadWebsiteData(website, false);
stopwatch.Stop();
Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);
stopwatch.Reset();
stopwatch.Start();
Console.WriteLine("No Cache Run");
LoadWebsiteData(website, false);
stopwatch.Stop();
Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);
stopwatch.Reset();
stopwatch.Start();
Console.WriteLine("Cached Run");
LoadWebsiteData(website, true);
stopwatch.Stop();
Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);
Console.WriteLine();
Console.WriteLine("Press any key to exit..");
Console.ReadKey();
}
private static string LoadWebsiteData(string webAddress, bool useCache)
{
string data = http://codecanyon.net/item/cachefabric/null;
string cacheKey = CacheKeys.GetMethodKey(webAddress);
if (useCache)
{
data = http://codecanyon.net/item/cachefabric/Cache.Get(cacheKey) as string;
}
if (data =http://codecanyon.net/item/cachefabric/= null)
{
using (var client = new WebClient())
{
data = http://codecanyon.net/item/cachefabric/client.DownloadString(webAddress);
Cache.Add(cacheKey, data);
}
}
return data;
}
}
}

To change the caching mechanism to AppFabric Caching, ASP.NET Caching, or no caching simply change the following lines of code as demonstrated below.

Distributed Caching – AppFabric

//static readonly ICacheManager CacheManager = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager();
//static readonly ICacheDirector Cache = new SingleServerCaching(CacheManager);
static readonly ICacheDirector Cache = new DistributedCaching(new DistributedCachingConfiguration
{
ApplicationCacheName = "MyCacheName",
ApplicationCacheRegion = "MyRegion" // Leave blank to use default region
});

Single Server Caching – Enterprise Library

//static readonly ICacheManager CacheManager = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager();
//static readonly ICacheDirector Cache = new SingleServerCaching(CacheManager);
static readonly ICacheDirector Cache = new DefaultAspNetCaching();

No Caching

//static readonly ICacheManager CacheManager = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager();
//static readonly ICacheDirector Cache = new SingleServerCaching(CacheManager);
static readonly ICacheDirector Cache = new NullCaching();

Google Custom Search .NET API; Event Log Writer; Background Work Scheduler.

Keywords: ASP.NET Cache, AppFabric, Cache Server, Distributed Caching, Enterprise Library, Enterprise Library Caching, NET Application Caching, NET Cache, Server Caching, Single Server Caching, c-sharp, cache, caching, caching data, performance.



Tags: Caching, Cache, Server, Library, Enterprise, Sharp

Premium CodeCanyon CacheFabric 3895224 WordPress Themes, Website Templates, Mobile Themes, Flash Templates & Scripts from creative professional designers. Full details of CodeCanyon CacheFabric 3895224 for digital design and education. CodeCanyon CacheFabric 3895224 desigen style information or anything related.

Comments:

Name:*
E-Mail:*
Add Comments:
Enter Code: *