/*
package com.muyu.carData.controller;

import com.github.benmanes.caffeine.cache.Cache;
import com.muyu.carData.config.cacheconfig.CaffeineConfig;
import com.muyu.carData.pojo.Student;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

*/
/**
 * @Author：张腾
 * @Package：com.muyu.carData.controller
 * @Project：cloud-server-8
 * @name：TestController
 * @Date：2024/9/26 23:56
 *//*

@RestController
@RequestMapping("/testCache")
@Log4j2
public class CacheController {

    @Autowired
    private CaffeineConfig caffeineConfig;

    @RequestMapping("/caffeine")
    public String caffeine() throws InterruptedException {
        Cache<String, Student> stringCache = (Cache<String, Student>) caffeineConfig.caffeineCache();
        Student build = Student.builder().id(1)
                .name("小马")
                .sex("男")
                        .expiryTime(20 * 60)
                                .refreshTime(15 * 30)
                                        .build();
        stringCache.put("1", build);
        Thread.sleep(1000);
        //返回缓存的个数
        log.info(stringCache.estimatedSize());
        //返回缓存的数据
        log.info(stringCache.getIfPresent("1"));
        return "111";
    }

}
*/
