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
package com.iplatform.tcp.cache;
 
import com.iplatform.model.po.TcpEquip;
import com.iplatform.tcp.Constants;
import com.iplatform.tcp.EquipmentCacheProvider;
import com.iplatform.tcp.service.TcpEquipServiceImpl;
import com.walker.cache.AbstractCacheProvider;
import com.walker.cache.Cache;
import com.walker.infrastructure.utils.StringUtils;
 
import java.util.List;
 
public class LocalEquipmentCacheProvider extends AbstractCacheProvider<TcpEquip> implements EquipmentCacheProvider {
 
    @Override
    protected int loadDataToCache(Cache cache) {
        List<TcpEquip> hosts = this.tcpEquipService.selectAll(new TcpEquip());
        if(!StringUtils.isEmptyList(hosts)){
            for(TcpEquip h : hosts){
                cache.put(h.getNum(), h);
            }
            return hosts.size();
        }
        return 0;
    }
 
    @Override
    public String getProviderName() {
        return Constants.CACHE_NAME_EQUIPMENT;
    }
 
    @Override
    public Class<?> getProviderType() {
        return TcpEquip.class;
    }
 
    public void setTcpEquipService(TcpEquipServiceImpl tcpEquipService) {
        this.tcpEquipService = tcpEquipService;
    }
 
    private TcpEquipServiceImpl tcpEquipService;
 
    @Override
    public void putEquipment(String key, TcpEquip tcpEquip) {
        this.putCacheData(key, tcpEquip);
    }
 
    @Override
    public TcpEquip getEquipment(String key) {
        return this.getCacheData(key);
    }
 
    @Override
    public void removeEquipment(String key) {
        this.removeCacheData(key);
    }
}