刘磊
2025-06-09 dabbcafc629ef87d11ba55ef8cc1cdc776c047d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace WIDESEA_Core.Caches
{
    /// <summary>
    /// 缓存抽象接口,基于IDistributedCache封装
    /// </summary>
    public interface ICaching
    {
        public IDistributedCache Cache { get; }
        void AddCacheKey(string cacheKey);
        Task AddCacheKeyAsync(string cacheKey);
 
        void DelByPattern(string key);
        Task DelByPatternAsync(string key);
 
        void DelCacheKey(string cacheKey);
        Task DelCacheKeyAsync(string cacheKey);
 
        bool Exists(string cacheKey);
        Task<bool> ExistsAsync(string cacheKey);
 
        List<string> GetAllCacheKeys();
        Task<List<string>> GetAllCacheKeysAsync();
 
        T Get<T>(string cacheKey);
        Task<T> GetAsync<T>(string cacheKey);
 
        object Get(Type type, string cacheKey);
        Task<object> GetAsync(Type type, string cacheKey);
 
        string GetString(string cacheKey);
        Task<string> GetStringAsync(string cacheKey);
 
        void Remove(string key);
        Task RemoveAsync(string key);
 
        void RemoveAll();
        Task RemoveAllAsync();
 
        void Set<T>(string cacheKey, T value, TimeSpan? expire = null);
        Task SetAsync<T>(string cacheKey, T value);
        Task SetAsync<T>(string cacheKey, T value, TimeSpan expire);
 
        void SetPermanent<T>(string cacheKey, T value);
        Task SetPermanentAsync<T>(string cacheKey, T value);
 
        void SetString(string cacheKey, string value, TimeSpan? expire = null);
        Task SetStringAsync(string cacheKey, string value);
        Task SetStringAsync(string cacheKey, string value, TimeSpan expire);
 
        Task DelByParentKeyAsync(string key);
    }
}