Search in sources :

Example 1 with CommonAPI

use of org.jeecg.common.api.CommonAPI in project kms by mahonelau.

the class DataSourceCachePool method getCacheDynamicDataSourceModel.

/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
    if (getRedisTemplate().hasKey(redisCacheKey)) {
        return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
    }
    CommonAPI commonAPI = SpringContextUtils.getBean(CommonAPI.class);
    DynamicDataSourceModel dbSource = commonAPI.getDynamicDbSourceByCode(dbKey);
    if (dbSource != null) {
        getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
    }
    return dbSource;
}
Also used : CommonAPI(org.jeecg.common.api.CommonAPI) DynamicDataSourceModel(org.jeecg.common.system.vo.DynamicDataSourceModel)

Example 2 with CommonAPI

use of org.jeecg.common.api.CommonAPI in project kykms by mahonelau.

the class DataSourceCachePool method getCacheDynamicDataSourceModel.

/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
    if (getRedisTemplate().hasKey(redisCacheKey)) {
        return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
    }
    CommonAPI commonAPI = SpringContextUtils.getBean(CommonAPI.class);
    DynamicDataSourceModel dbSource = commonAPI.getDynamicDbSourceByCode(dbKey);
    if (dbSource != null) {
        getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
    }
    return dbSource;
}
Also used : CommonAPI(org.jeecg.common.api.CommonAPI) DynamicDataSourceModel(org.jeecg.common.system.vo.DynamicDataSourceModel)

Example 3 with CommonAPI

use of org.jeecg.common.api.CommonAPI in project jeecg-boot by jeecgboot.

the class DataSourceCachePool method getCacheDynamicDataSourceModel.

/**
 * 获取多数据源缓存
 *
 * @param dbKey
 * @return
 */
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
    String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
    if (getRedisTemplate().hasKey(redisCacheKey)) {
        return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
    }
    CommonAPI commonAPI = SpringContextUtils.getBean(CommonAPI.class);
    DynamicDataSourceModel dbSource = commonAPI.getDynamicDbSourceByCode(dbKey);
    if (dbSource != null) {
        getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
    }
    return dbSource;
}
Also used : CommonAPI(org.jeecg.common.api.CommonAPI) DynamicDataSourceModel(org.jeecg.common.system.vo.DynamicDataSourceModel)

Aggregations

CommonAPI (org.jeecg.common.api.CommonAPI)3 DynamicDataSourceModel (org.jeecg.common.system.vo.DynamicDataSourceModel)3