All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.ymate.platform.cache.impl.MultilevelCacheProvider Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
/*
 * Copyright 2007-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.ymate.platform.cache.impl;

import net.ymate.platform.cache.AbstractRedisCacheProvider;
import net.ymate.platform.cache.ICache;
import net.ymate.platform.cache.ICacheEventListener;
import net.ymate.platform.cache.support.MultilevelCacheWrapper;
import net.ymate.platform.persistence.redis.IRedis;

/**
 * @author 刘镇 ([email protected]) on 15/12/6 上午4:58
 */
public class MultilevelCacheProvider extends AbstractRedisCacheProvider {

    private IRedis redis;

    @Override
    public String getName() {
        return ICache.MULTILEVEL;
    }

    @Override
    protected void onInitialize() throws Exception {
        super.onInitialize();
        //
        redis = REDIS_CREATOR.create();
        redis.initialize(getOwner().getOwner());
    }

    @Override
    protected void onDestroy() throws Exception {
        super.onDestroy();
        //
        redis.close();
        redis = null;
    }

    @Override
    protected ICache onCreateCache(String cacheName, ICacheEventListener listener) {
        ICache cache = getCacheManager().createCache(cacheName, listener);
        return new MultilevelCacheWrapper(getOwner(), cacheName, cache, redis);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy