Spring学习之缓存机制EhCache---Key

来源:互联网 发布:淘宝无人机 编辑:程序博客网 时间:2024/05/22 01:58

UserService.java

package com.kinsey.woo.service.impl;import org.springframework.cache.annotation.Cacheable;import org.springframework.stereotype.Service;import com.kinsey.woo.dto.User;import com.kinsey.woo.service.UserService;@Service("userService")@Cacheable(value="users",key="#name")public class UserServiceImpl implements UserService {public User getUserByNameAndAge(String name,int age){System.out.print("getUserByNameAndAge is called...\n");return new User(name,age);}@Overridepublic User getAntherUser(String name, int age) {System.out.println("getAntherUser is called...\n");return new User(name,age);}}


0 0