static CacheHelper() { //new RedisCacheWriter(); IApplicationContext ctx = ContextRegistry.GetContext(); CacheWriter = ((IObjectFactory)ctx).GetObject("CacheWriter") as ICacheWriter; }
static CacheHelper() { IApplicationContext ctx = ContextRegistry.GetContext();//这是Spring支持的得到Context的方式 //ctx.GetObject("CacheHelper"); CacheHelper.CacheWriter = ctx.GetObject("CacheWriter") as ICacheWriter; }
private void SetCacheWriter(string regionName, ICacheWriter <string, string> writer) { GIRegion region = CacheHelper.GetVerifyRegion <string, string>(regionName); AttributesMutator <string, string> attrMutator = region.AttributesMutator; attrMutator.SetCacheWriter(writer); }
public HomeController(IUserInfoService serviceParam, IActionInfoService actionServiceParam, ICacheWriter cacheWriterParam) { usersService = serviceParam; actionService = actionServiceParam; cacheWriter = cacheWriterParam; }
static CacheHelper() { #if NFX461 CacheWriter = new MemoryCacheWriter(); #elif NETCORE CacheWriter = null; #endif }
static CacheHelper() { //通过容器创建对象,实现属性注入(因为属性是静态的,可以不创建实例就使用,但不创建实例属性就是空的) IApplicationContext context = ContextRegistry.GetContext(); //context.GetObject("CacheHelper");//属性注入 CacheHelper.CacheWriter = context.GetObject("CacheWriter") as ICacheWriter; //直接通过容器 }
static CacheHelper() { //走一个容器来创建一个CacheWriter实例、初始化Spring.net IApplicationContext ctx = ContextRegistry.GetContext(); //ctx.GetObject("CacheWriter"); CacheHelper.CacheWriter = ctx.GetObject("RedisCacheWriter") as ICacheWriter; }
static CacheHelper() { //通过容器创建一个对象 IApplicationContext ctx = ContextRegistry.GetContext(); //ctx.GetObject("CacheHelper"); CacheHelper.CacheWriter = ctx.GetObject("CacheWriter") as ICacheWriter; }
static CacheHelper() { //这里存在一些问题 ContainerBuilder containerBuilder = new ContainerBuilder(); IContainer container = containerBuilder.Build(); CacheHelper.CacheWriter = container.Resolve <ICacheWriter>(); }
static CacheHelper() { //因为是静态的方法,如果需要依赖注入的方式进行赋值的话,首先需要注入一个ICachewriter的对象 IApplicationContext ctx = ContextRegistry.GetContext(); ctx.GetObject("CacheHelper"); CacheWriter = (ICacheWriter)ctx.GetObject("CacheWriter"); }
public UnboundedLocalCache(Caffeine <K, V> builder, bool isAsync, int concurrencyLevel) { this.data = new ConcurrentDictionary <K, V>(concurrencyLevel, builder.InitialCapacity); this.statsCounter = builder.StatsCounter.Get(); this.removalListener = builder.RemovalListener; this.isRecordingStats = builder.IsRecordingStats; this.writer = builder.Writer; this.ticker = builder.Ticker; }
public void Initialize() { header = GetHeader(); cacheWriter = SharedCacheFactory.Instance.CacheWriter; cacheWriter.RegisterHeader(header); cacheReader = SharedCacheFactory.Instance.CacheReader; cacheReader.RegisterHeader(header); }
static CacheHelper() { CacheHelper.CacheWriter = new RedisCache(); }
public SequenceKeyedCaching(CacheHeaderInfo header, ICacheWriter cacheWriter, ICacheReader cacheReader) { this.header = header; this.cacheWriter = cacheWriter; this.cacheReader = cacheReader; }
static CacheHelper() { //IApplicationContext ctx = ContextRegistry.GetContext(); CacheWriter = new MemcacheWriter(); //ctx.GetObject("CacheWriter") as ICacheWriter; }
static CacheHelper() { CacheHelper.CacheWriter = new MemcacheWriter(); }
/// <summary> /// Specifies a writer instance that caches should notify each time an entry is explicitly created /// or modified, or removed for any <see cref="RemovalCause"/> reason. The writer is not notified /// when an entry is loaded or computed. Each cache created by this builder will invoke this /// writer as part of the atomic operation that modifies the cache. /// </summary> /// <param name="writer"></param> /// <returns></returns> /// <exception cref="InvalidOperationException">If a writer was already set or if the <see cref="KeyStrength"/> is weak</exception> /// <exception cref="ArgumentNullException">If the writer is <see langword="null"/></exception> public Caffeine <K, V> SpecifyWriter(ICacheWriter <K, V> writer) { Writer = writer; return(this); }