/// <summary> /// Default constructor. /// </summary> /// <param name="storageProvider">The cache store to be wrapped.</param> public StorageProviderSyncWrapper(StorageProviderBase storageProvider) { if (storageProvider == null) throw new ArgumentNullException("storageProvider"); _storage = storageProvider; _syncObj = _storage.Sync; }
/// <summary> /// Internal method that creates a cache store. A HashMap containing the config parameters /// is passed to this method. /// </summary> public static ICacheStorage CreateStorageProvider(IDictionary properties, string cacheContext, bool evictionEnabled, ILogger NCacheLog, IAlertPropagator alertPropagator) { if (properties == null) { throw new ArgumentNullException("properties"); } StorageProviderBase cacheStorage = null; try { if (!properties.Contains("class")) { throw new ConfigurationException("Missing cache store class."); } string scheme = Convert.ToString(properties["class"]).ToLower(); IDictionary schemeProps = (IDictionary)properties[scheme]; if (scheme.CompareTo("heap") == 0) { cacheStorage = new ClrHeapStorageProvider(schemeProps, evictionEnabled, NCacheLog, alertPropagator); } else if (scheme.CompareTo("memory") == 0) { cacheStorage = new InMemoryStorageProvider(schemeProps, evictionEnabled); } else if (scheme.CompareTo("memory-mapped") == 0) { cacheStorage = new MmfStorageProvider(schemeProps, evictionEnabled); } else if (scheme.CompareTo("file") == 0) { cacheStorage = new FileSystemStorageProvider(schemeProps, evictionEnabled); } else { throw new ConfigurationException("Invalid cache store class: " + scheme); } if (cacheStorage != null) { cacheStorage.CacheContext = cacheContext; } } catch (ConfigurationException e) { Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString()); throw; } catch (Exception e) { Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString()); throw new ConfigurationException("Configuration Error: " + e.ToString(), e); } return(cacheStorage); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or /// resetting unmanaged resources. /// </summary> public override void Dispose() { if (_storage != null) { _storage.Dispose(); _storage = null; } base.Dispose(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="storageProvider">The cache store to be wrapped.</param> public StorageProviderSyncWrapper(StorageProviderBase storageProvider) { if (storageProvider == null) { throw new ArgumentNullException("storageProvider"); } _storage = storageProvider; _syncObj = _storage.Sync; }
/// <summary> /// Internal method that creates a cache store. A HashMap containing the config parameters /// is passed to this method. /// </summary> public static ICacheStorage CreateStorageProvider(IDictionary properties, string cacheContext, bool evictionEnabled, ILogger NCacheLog) { if (properties == null) { throw new ArgumentNullException("properties"); } StorageProviderBase cacheStorage = null; try { string scheme = "heap"; IDictionary schemeProps = (IDictionary)properties[scheme]; if (scheme.CompareTo("heap") == 0) { cacheStorage = new ClrHeapStorageProvider(schemeProps, evictionEnabled, NCacheLog); } if (cacheStorage != null) { cacheStorage.CacheContext = cacheContext; } } catch (ConfigurationException e) { Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString()); throw; } catch (Exception e) { Trace.error("CacheStorageFactory.CreateCacheStore()", e.ToString()); throw new ConfigurationException("Configuration Error: " + e.ToString(), e); } return(cacheStorage); }
/// <summary> /// Returns the thread safe synchronized wrapper over cache store. /// </summary> /// <param name="storageProvider"></param> /// <returns></returns> public static StorageProviderBase Synchronized(StorageProviderBase cacheStorage) { return(new StorageProviderSyncWrapper(cacheStorage)); }
/// <summary> /// Returns the thread safe synchronized wrapper over cache store. /// </summary> /// <param name="storageProvider"></param> /// <returns></returns> public static StorageProviderBase Synchronized(StorageProviderBase cacheStorage) { return new StorageProviderSyncWrapper(cacheStorage); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or /// resetting unmanaged resources. /// </summary> public override void Dispose() { if (_storage != null) { _storage.Dispose(); _storage = null; } base.Dispose(); }