using System; using System.Collections.Generic; namespace VCommon.Caching { public class FixedCacheManager { private readonly int _fixedDb; private readonly CacheManager _underlying; public FixedCacheManager(string server, int fixedDb) { _fixedDb = fixedDb; _underlying = new CacheManager(server); } public void KeyExpire(string key, CacheExpire expire) => _underlying.KeyExpire(_fixedDb, key, expire); public bool KeyExist(string key) => _underlying.KeyExist(_fixedDb, key); public bool KeyDelete(string key) => _underlying.KeyDelete(_fixedDb, key); public void KeySetJson(string key, object value, CacheExpire expire = null) => _underlying.KeySetJson(_fixedDb, key, value, expire); public T KeyGetJson(string key) => _underlying.KeyGetJson(_fixedDb, key); public T KeyGetFetchJson(string key, Func missProvider, CacheExpire expire = null) => _underlying.KeyFetchJson(_fixedDb, key, missProvider, expire); public CacheValue KeyGetFetch(string key, Func missProvider, CacheExpire expire = null) => _underlying.KeyFetch(_fixedDb, key, missProvider, expire); public void KeySet(string key, CacheValue value, CacheExpire expire = null) => _underlying.KeySet(_fixedDb, key, value, expire); public CacheValue KeyGet(string key) => _underlying.KeyGet(_fixedDb, key); public bool HashFieldExist(string hashKey, string hashField) => _underlying.HashFieldExist(_fixedDb, hashKey, hashField); public bool HashFieldDelete(string hashKey, string hashField) => _underlying.HashFieldDelete(_fixedDb, hashKey, hashField); public long HashFieldDelete(string hashKey, params string[] hashFields) => _underlying.HashFieldDelete(_fixedDb, hashKey, hashFields); public CacheValue HashFieldFetch(string hashKey, string hashField, Func missingCacheValueProvider, CacheExpire expire = null) => _underlying.HashFieldFetch(_fixedDb, hashKey, hashField, missingCacheValueProvider, expire); public T HashFieldFetchJson(string hashKey, string hashField, Func missingCacheValueProvider, CacheExpire expire = null) => _underlying.HashFieldFetchJson(_fixedDb, hashKey, hashField, missingCacheValueProvider, expire); public void HashFieldSetJson(string hashKey, string hashField, T value, CacheExpire expire = null) => _underlying.HashFieldSetJson(_fixedDb, hashKey, hashField, value, expire); public void HashFieldSetJson(string hashKey, IReadOnlyDictionary entries, CacheExpire expire = null) => _underlying.HashFieldSetJson(_fixedDb, hashKey, entries, expire); public T HashFieldGetJson(string hashKey, string hashField) => _underlying.HashFieldGetJson(_fixedDb, hashKey, hashField); public void HashFieldPurgeAndSet(string hashKey, IReadOnlyDictionary hashFields) => _underlying.HashFieldPurgeAndSet(_fixedDb, hashKey, hashFields); public void HashFieldDeleteByPattern(string hashKey, string pattern) => _underlying.HashFieldDeleteByPattern(_fixedDb, hashKey, pattern); public IReadOnlyDictionary HashFieldGetByPattern(string hashKey, string pattern) => _underlying.HashFieldGetByPattern(_fixedDb, hashKey, pattern); public IReadOnlyDictionary HashFieldGetByPatternJson(string hashKey, string pattern) => _underlying.HashFieldGetByPatternJson(_fixedDb, hashKey, pattern); public void HashFieldSet(string hashKey, string hashField, CacheValue value, CacheExpire expire = null) => _underlying.HashFieldSet(_fixedDb, hashKey, hashField, value, expire); public CacheValue HashFieldGet(string hashKey, string hashField) => _underlying.HashFieldGet(_fixedDb, hashKey, hashField); public void HashFieldSet(string hashKey, IReadOnlyDictionary hashField, CacheExpire expire = null) => _underlying.HashFieldSet(_fixedDb, hashKey, hashField, expire); public long HashFieldIncrement(string hashKey, string hashField) => _underlying.HashFieldIncrement(_fixedDb, hashKey, hashField); public long HashFieldDecrement(string hashKey, string hashField) => _underlying.HashFieldDecrement(_fixedDb, hashKey, hashField); public IReadOnlyDictionary HashFieldGet(string hashKey, params string[] hashFields) => _underlying.HashFieldGet(_fixedDb, hashKey, hashFields); public IReadOnlyDictionary HashFieldsFetchAsDic(string key, IEnumerable hashFields, Func convertHashField, Func, IReadOnlyDictionary> missingCacheValueProvider, Func convertValueToCache, Func convertCacheToValue, CacheExpire expire = null) => _underlying.HashFieldsFetchAsDic(_fixedDb, key, hashFields, convertHashField, missingCacheValueProvider, convertValueToCache, convertCacheToValue, expire); public string[] SearchKeys(string pattern) => _underlying.SearchKeys(_fixedDb, pattern); } }