本文介绍了DataCacheFactory静态类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在许多wcf服务中使用appfabric缓存。

Hi, i use the appfabric caching in many wcf services.

因为(我读过这个),新的DataCacheFactory是一个非常昂贵的指令,我使用的是class是缓存方法的包装器。

Because (i read this), the new DataCacheFactory is an instruction very expensive, i use a my class that is a wrapper for caching methods.


 public sealed class CacheManager
    {
        static string _namedCache = "";
        
        private static DataCacheFactory _factory= null;
        private static DataCache _cache = null;

        private static CacheManager _instance=null;

        private CacheManager(string cacheName)
        {
            _namedCache = cacheName;
            _factory = new DataCacheFactory();
            _cache = _factory.GetCache(_namedCache);
        }

        public static CacheManager Instance(string cacheName)
        {
            if (_instance == null)
            {
                lock (typeof(CacheManager))
                {
                    _instance = new CacheManager(cacheName);
                }
            }
            return _instance;
        }

推荐答案


这篇关于DataCacheFactory静态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:34