use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class TenantServiceImpl method getByCode.
/**
* tenant_name:{tenantCode} -> id 只存租户的id,然后根据id再次查询缓存,这样子的好处是,删除或者修改租户信息时,只需要根据id淘汰缓存即可
* 缺点就是 每次查询,需要多查一次缓存
*
* @param tenant
* @return
*/
@Override
public Tenant getByCode(String tenant) {
Function<CacheKey, Object> loader = (k) -> getObj(Wraps.<Tenant>lbQ().select(Tenant::getId).eq(Tenant::getCode, tenant), Convert::toLong);
CacheKey cacheKey = new TenantCodeCacheKeyBuilder().key(tenant);
return getByKey(cacheKey, loader);
}
use of com.albedo.java.common.core.cache.model.CacheKey in project albedo by somowhere.
the class AbstractCacheServiceImpl method setCache.
protected void setCache(T model) {
Object id = getId(model);
if (id != null) {
CacheKey key = cacheKeyBuilder().key(id);
cacheOps.set(key, model);
}
}
Aggregations