redis注記方式------CAcheable

2249 ワード

@Service
public class cacheableServiceImpl implements cacheableService {
    /**
     *      ,   key    SimpleKey []
     *
     *  :         key  ,  keyGenerator
     */
    @Cacheable(cacheNames = "TestKeySpace")
    @Override
    public void methodOne() {
        System.out.println("cha ");
    }
    /**
     *          ,   key          toString  
     *  :      ,             paramA,   key  paramA
     *
     *  :         key  ,  keyGenerator
     */
    @Cacheable(cacheNames = "TestKeySpace")
    @Override
    public void methodTwo(String chen) {
        System.out.println("cha ");
    }


    /**
     *          ,   key           toString  
     *  :      ,         User  ,       User   toString    key
     *
     *  :         key  ,  keyGenerator
     */
    @Cacheable(cacheNames = "TestKeySpace")
    @Override
    public User methodThree(User user) {
        System.out.println("cha ");
        return user;
    }




    @Cacheable(cacheNames = "TestKeySpace")
    @Override
    public void methodfour(Map objectObjectMap) {
        System.out.println("cha ");
    }

    /**
     *    :       key  ,        key     (       KeyGenerator)
     *
     *    :   key     ,        ''   
     *
     */
    @Cacheable(cacheNames = "TestKeySpace", key = "'i_am_key'")
    @Override
    public void methodfive(String dfdfdfdf) {
        System.out.println("cha ");
    }
    /**
     *    :       key  ,        key     (       KeyGenerator)
     *
     *    :        Spring Expression Language (SpEL)    key    ,
     *            【#   】   【#p    】          
     *
     *   :     key = "#str"     key = "#p0"     key = "#a0"
     *          :p params ,   a   args
     */
    @Cacheable(cacheNames = "TestKeySpace", key = "#str")
    @Override
    public void methodSeven(String str) {
        System.out.println("cha ");
    }



    
    @Cacheable(cacheNames = "TestKeySpace", key = "#str.hashCode() + '*****' + #p1.name")
    @Override
    public void methodEight(String str, User user) {

    }


}