12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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<T>(string key) => _underlying.KeyGetJson<T>(_fixedDb, key);
- 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<CacheValue> missingCacheValueProvider, CacheExpire expire = null) => _underlying.HashFieldFetch(_fixedDb, hashKey, hashField, missingCacheValueProvider, expire);
- public T HashFieldFetchJson<T>(string hashKey, string hashField, Func<T> missingCacheValueProvider, CacheExpire expire = null) => _underlying.HashFieldFetchJson(_fixedDb, hashKey, hashField, missingCacheValueProvider, expire);
- public void HashFieldSetJson<T>(string hashKey, string hashField, T value, CacheExpire expire = null) => _underlying.HashFieldSetJson(_fixedDb, hashKey, hashField, value, expire);
- public void HashFieldSetJson<T>(string hashKey, IReadOnlyDictionary<string, T> entries, CacheExpire expire = null) => _underlying.HashFieldSetJson(_fixedDb, hashKey, entries, expire);
- public T HashFieldGetJson<T>(string hashKey, string hashField) => _underlying.HashFieldGetJson<T>(_fixedDb, hashKey, hashField);
- public void HashFieldPurgeAndSet(string hashKey, IReadOnlyDictionary<string, CacheValue> hashFields) => _underlying.HashFieldPurgeAndSet(_fixedDb, hashKey, hashFields);
- public void HashFieldDeleteByPattern(string hashKey, string pattern) => _underlying.HashFieldDeleteByPattern(_fixedDb, hashKey, pattern);
- public IReadOnlyDictionary<string, CacheValue> HashFieldGetByPattern(string hashKey, string pattern) => _underlying.HashFieldGetByPattern(_fixedDb, hashKey, pattern);
- public IReadOnlyDictionary<string, T> HashFieldGetByPatternJson<T>(string hashKey, string pattern) => _underlying.HashFieldGetByPatternJson<T>(_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<string, CacheValue> 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<string, CacheValue> HashFieldGet(string hashKey, params string[] hashFields) => _underlying.HashFieldGet(_fixedDb, hashKey, hashFields);
- public IReadOnlyDictionary<TK, TV> HashFieldsFetchAsDic<TK, TV>(string key, IEnumerable<TK> hashFields,
- Func<TK, string> convertHashField,
- Func<IEnumerable<TK>, IReadOnlyDictionary<TK, TV>> missingCacheValueProvider,
- Func<TV, CacheValue> convertValueToCache,
- Func<CacheValue, TV> convertCacheToValue,
- CacheExpire expire = null) => _underlying.HashFieldsFetchAsDic(_fixedDb, key, hashFields, convertHashField, missingCacheValueProvider, convertValueToCache, convertCacheToValue, expire);
- public string[] SearchKeys(string pattern) => _underlying.SearchKeys(_fixedDb, pattern);
- }
- }
|