Skip to content

Instantly share code, notes, and snippets.

@jbest84
Created September 14, 2012 23:35
Show Gist options
  • Save jbest84/3725609 to your computer and use it in GitHub Desktop.
Save jbest84/3725609 to your computer and use it in GitHub Desktop.
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);
}
}
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