NCache is an extremely fast and scalable In-Memory Distributed Cache for .NET that caches application data to reduce expensive database trips. You can use NCache to remove performance bottlenecks associated with your data storage and database scalability.
The most common way to use such a cache is to let your application read data from your database/data source and then caches it. After which, when your application updates this data in your database, it also updates the cache to ensure the cache is in sync with the database.
Furthermore, NCache provides another very powerful mechanism for reading and writing data called Data source Providers (Read-through/Write-through/Write-behind) to let NCache read and write data from your database.
There are three ways you can use NCache in this context:
Here are some benefits of using Read-through, Write-through, and Write-behind in NCache.
Here are some highlights of Read-through, Write-through, and Write-behind in NCache.
Developing code for Read-through and Write-through Handlers is a straightforward process. Below are examples of interfaces for both.
public interface IReadThruProvider
{
void Init(IDictionary parameters, string cacheId);
ProviderCacheItem LoadFromSource(string key);
IDictionary<string, ProviderCacheItem> LoadFromSource(ICollection<string> keys);
ProviderDataTypeItem<IEnumerable> LoadDataTypeFromSource(string key, DistributedDataType dataType);
void Dispose();
}
public interface ReadThruProvider extends java.lang.AutoCloseable
{
void init(java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String cacheId) throws java.lang.Exception;
ProviderCacheItem loadFromSource(java.lang.String key) throws java.lang.Exception;
java.util.Map<java.lang.String,ProviderCacheItem> loadFromSource(java.util.Collection<java.lang.String> keys) throws java.lang.Exception;
ProviderDataStructureItem loadDataStructureFromSource(java.lang.String key, DistributedDataStructureType distributedDataStructureType) throws java.lang.Exception;
}
public interface IWriteThruProvider
{
void Init(IDictionary parameters, string cacheId);
OperationResult WriteToDataSource(WriteOperation operation);
ICollection<OperationResult> WriteToDataSource(ICollection<WriteOperation> operations);
ICollection<OperationResult> WriteToDataSource(ICollection<DataTypeWriteOperation> dataTypeWriteOperations);
void Dispose();
}
public interface WriteThruProvider extends java.lang.AutoCloseable
{
void init(java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String cacheId) throws java.lang.Exception;
OperationResult writeToDataSource(WriteOperation operation) throws java.lang.Exception;
java.util.Collection<OperationResult> writeToDataSource(java.util.Collection<WriteOperation> operations) throws java.lang.Exception;
java.util.Collection<OperationResult> writeDataStructureToDataSource(java.util.Collection<DataStructureWriteOperation< dataStructureWriteOperations) throws java.lang.Exception;
}
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.