Spring @cacheable

1. Hello cache

1.1. spring cache XML配置




    
    

    
        
    

    
        
    

    
        
    


    
        
            
            
            
                
                    0
                
                
                    
                    
                        127.0.0.1
                    
                
                
                    10.10.1.*
                
                
                
                
            
            
            

            

            

            

            

            

            

            

            
        
    
 


1.2. hello world

    @Cacheable("test")
    public String testCache() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "test";
    }

调用此方法,第一次会sleep 2000ms,后面都会直接返回结果,表示缓存成功。

1.3 其他注解

  • @Cacheable
    triggers cache population
  • @CacheEvict
    triggers cache eviction
  • @CachePut
    updates the cache without interfering with the method execution
  • @Caching
    regroups multiple cache operations to be applied on a method
  • @CacheConfig
    shares some common cache-related settings at class-level

注解文档

2. Hazelcast

2.1 feature

Spring @cacheable_第1张图片
Paste_Image.png

2.2 docs

Get start
spring Integration docs
Map Configuration

你可能感兴趣的:(Spring @cacheable)