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

com.github.bingoohuang.springrediscache.RedisCacheConnector Maven / Gradle / Ivy

The newest version!
package com.github.bingoohuang.springrediscache;

import com.google.common.base.Optional;
import com.google.common.base.Throwables;

import java.util.concurrent.Callable;

public class RedisCacheConnector {
    static ThreadLocal> threadLocal = new ThreadLocal>();

    public static  T connectCache(Callable callable, Object cachedValue) {
        threadLocal.set(Optional.fromNullable(cachedValue));
        try {
            return callable.call();
        } catch (Exception e) {
            throw Throwables.propagate(e);
        } finally {
            threadLocal.remove();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy