Azure - 用于减慢多实例的Windows Azure缓存的替代方法

时间:2012-04-27 14:25:23

标签: caching azure azure-storage

我们目前将现有的Web应用程序移至Azure。 Azure缓存为very slow

Azure中的多实例是否有 备用缓存机制 (优于Azure缓存)?例如,在Azure存储或Azure SQL中存储缓存。

感谢您的投入!

public class AzureCacheService : ICacheService
{
    readonly DataCacheFactory _factory = new DataCacheFactory();

    private readonly DataCache _cache;

    public AzureCacheService()
    {
        _cache = _factory.GetDefaultCache();
    }

    public object Get(string key)
    {
        return _cache.Get(key);
    }

    public void Insert(string key, object obj)
    {
        if (obj != null)
        {
            _cache.Put(key, obj, new TimeSpan(3, 0, 0));
        }
    }

    public void Remove(string key)
    {
        _cache.Remove(key);
    }
}

*** Accessing *** 
IoC.Resolve<ICacheService>().Insert(key, MyObject);

IoC.Resolve<ICacheService>().Remove(key);

3 个答案:

答案 0 :(得分:2)

通常,WA缓存慢,特别是如果您打开“本地缓存”(通常应该将延迟降低到0ms左右,只要数据适合内存)。 Memcached是另一种可能性:http://blog.smarx.com/posts/memcached-in-windows-azure

你不会在WA Caching和Memcached之间找到性能上的数量级差异,但根据我的经验,Memcached的速度要快一些。但是,Memcached 不会能够击败WA缓存中的“本地缓存”功能,因为它实际上没有延迟。 (它是没有序列化的进程内数据访问。尽可能高效。)

答案 1 :(得分:0)

我误解了Windows Azure缓存是基于SQL Azure的,在获取正确的资源之后,我能够验证它确实是内存缓存。因此,如果您决定使用SQL Azure编写自己的版本,那么您现在已经获得的速度要慢得多,而Azure表存储也是如此。 [删除其他评论]

答案 2 :(得分:0)

您可以使用最近发布的Windows Azure缓存(预览)。它比共享缓存对手提高了5倍。

链接:http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/