IMembaseClientWrapper IMembaseClientWrapperFactory.CreateWithBucket(string configPath, string bucketName) { var key = configPath + "++" + bucketName; IMembaseClientWrapper retval; if (!cache.TryGetValue(key, out retval)) lock (cache) if (!cache.TryGetValue(key, out retval)) { var config = this.Load(configPath, null); cache[key] = retval = new MembaseClientWrapper(config, bucketName); } return retval; }
IMemcachedClientWrapper IMembaseClientWrapperFactory.CreateWithBucket(string configPath, string bucketName, string bucketPassword) { if (String.IsNullOrEmpty(configPath)) throw new ArgumentNullException("configPath"); if (!File.Exists(configPath)) throw new FileNotFoundException("File not found: " + configPath); var key = ("MB@" + configPath + "@" + (bucketName ?? "\u0000") + "@" + (bucketPassword ?? "\u0000")).ToUpperInvariant(); IMemcachedClientWrapper retval; var cache = HttpRuntime.Cache; if ((retval = cache[key] as IMemcachedClientWrapper) == null) lock (cache) if ((retval = cache[key] as IMemcachedClientWrapper) == null) { var config = this.Load(configPath, null); retval = new MembaseClientWrapper(config, bucketName, bucketPassword); cache.Insert(key, retval, new System.Web.Caching.CacheDependency(configPath)); } return retval; }