死siua11 发表于 2017-4-16 09:42:34

Memcache--从缓存中填充值

开发者博客:http://www.developsearch.com

//查看学生课堂表现
//从数据库中查询出学生的课堂表现列表,这个列表中只存了学生的ID,但是我们的目的是还要得到学生的姓名
List<LessonBehave> lessonBehaveList = lessonBehaveDao.queryLessonBehaveForList(request);
if (CollectionUtils.isNotEmpty(lessonBehaveList)) {
//从缓存中填充学生姓名的值到lessonBehaveList中
MemcachedUtils.fillingListObject(lessonBehaveList, LessonBehave.class);
}
//在实例字段上添加@CacheField注示
public class LessonBehave{
//学生编号
private String studentId;
//学生姓名
@CacheField(keyName = "studentId", dictType = DictType.USER_SIMPLEINFO_NAME)
private String studentName;
//省略get、set方法
}


另外参考文件:
commonserver/src/com/tianwen/eeducation/server/memcached/utils/MemcachedUtils.java
commonserver/src/com/tianwen/eeducation/server/common/annotation/CachedFieldPropertyManager.java
commonserver/resources/mapping/ds0/framework/model/dictitem-sql-pgsql.xml
页: [1]
查看完整版本: Memcache--从缓存中填充值