shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
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
60
61
62
63
package com.iplatform.base.cache;
 
import com.iplatform.base.Constants;
import com.iplatform.base.WechatCacheProvider;
import com.iplatform.base.WechatConstants;
import com.walker.cache.AbstractCacheProvider;
import com.walker.cache.Cache;
 
public class LocalWechatCache extends AbstractCacheProvider<String> implements WechatCacheProvider {
 
    @Override
    public String getMiniAccessToken() {
        return this.getCacheData(WechatConstants.REDIS_WECAHT_MINI_ACCESS_TOKEN_KEY);
    }
 
    @Override
    public String getJsApiTicket() {
        return this.getCacheData(WechatConstants.REDIS_PUBLIC_JS_API_TICKET);
    }
 
    @Override
    public String getPublicAccessToken() {
//        throw new UnsupportedOperationException("请使用Redis实现");
        return this.getCacheData(WechatConstants.REDIS_WECAHT_PUBLIC_ACCESS_TOKEN_KEY);
    }
 
    @Override
    public void putPublicAccessToken(String value, long expiredSeconds) {
//        throw new UnsupportedOperationException("请使用Redis实现");
        this.putCacheData(WechatConstants.REDIS_WECAHT_PUBLIC_ACCESS_TOKEN_KEY, value, expiredSeconds);
    }
 
    @Override
    public void putJsApiTicket(String value) {
//        throw new UnsupportedOperationException("请使用Redis实现");
        this.putCacheData(WechatConstants.REDIS_PUBLIC_JS_API_TICKET, value, WechatConstants.REDIS_PUBLIC_JS_API_TICKET_EXPRESS);
    }
 
    @Override
    public void putMiniAccessToken(String value, long expiredSeconds) {
        this.putCacheData(WechatConstants.REDIS_WECAHT_MINI_ACCESS_TOKEN_KEY, value, expiredSeconds);
    }
 
    @Override
    public void removeMiniAccessToken() {
        this.removeCacheData(WechatConstants.REDIS_WECAHT_MINI_ACCESS_TOKEN_KEY);
    }
 
    @Override
    protected int loadDataToCache(Cache cache) {
        return 0;
    }
 
    @Override
    public String getProviderName() {
        return Constants.CACHE_NAME_WECHAT;
    }
 
    @Override
    public Class<?> getProviderType() {
        return String.class;
    }
}