Created
September 14, 2012 23:35
-
-
Save jbest84/3725609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Sage.Platform.Application.Caching | |
{ | |
// Summary: | |
// Implementers provides support for caching | |
public interface ICache | |
{ | |
// Summary: | |
// Gets the name of the cache region | |
string RegionName { get; } | |
// Summary: | |
// Compare the provided cas with the value in the cache, and set if they are | |
// equal. | |
CasResult<bool> Cas(object key, object value, ulong cas); | |
// | |
// Summary: | |
// Clear the Cache | |
// | |
// Exceptions: | |
// !:CacheException: | |
void Clear(); | |
// | |
// Summary: | |
// Get the object from the Cache | |
// | |
// Parameters: | |
// key: | |
object Get(object key); | |
// | |
// Summary: | |
// Get the object from the Cache | |
T Get<T>(object key) where T : class; | |
// | |
// Summary: | |
// Get the object and associated unique CAS id from the Cache | |
CasResult<object> GetWithCas(object key); | |
// | |
// Summary: | |
// Get the object and associated unique CAS id from the Cache | |
CasResult<T> GetWithCas<T>(object key) where T : class; | |
// | |
// Summary: | |
// Sets or replaces the object identified by key | |
void Put(object key, object value); | |
// | |
// Summary: | |
// Remove an item from the Cache. | |
// | |
// Parameters: | |
// key: | |
// The Key of the Item in the Cache to remove. | |
// | |
// Exceptions: | |
// !:CacheException: | |
void Remove(object key); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cp = Sage.Platform.Application.ApplicationContext.Current.Services.Get<ICacheProvider>(false); | |
if (cp != null) | |
{ | |
// BuildCache returns a type of ICache | |
Sage.Platform.Caches.Memcached memcache = cp.BuildCache("regionName", null); | |
// Use memcache.Put, Get, etc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment