1

class JedisHelper {
    public static <T, R> T getBySecond(String cacheKey, int seconds, R p, Function<Object, T> function) {
        return function.apply(p);

    }

    public static <T> T getBySecond(String cacheKey, int seconds, Supplier<T> function) {
        return function.get();
    }
}

 

2.调用方法

 

 String value33 = JedisHelper.getBySecond("ad", 1, null, new Function<Object, String>() {
            @Override
            public String apply(Object o) {
                return "ccc";
            }
        });

        String prefix = "a";
        String value34 = JedisHelper.getBySecond("ad", 1, prefix, new Function<Object, String>() {
            @Override
            public String apply(Object o) {
                return prefix + "ccc";
            }
        });


        String value35 = JedisHelper.getBySecond("ad", 1, () -> {
            return prefix + "ccc";
        });

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案