Packagecom.liying.tiger.test;Importjava.util.List;ImportOrg.springframework.context.ApplicationContext;ImportOrg.springframework.context.support.ClassPathXmlApplicationContext;ImportOrg.springframework.data.domain.Page;ImportOrg.springframework.data.domain.PageImpl;ImportCom.liying.monkey.core.util.JavaJsonConvert;ImportCom.liying.monkey.dao.pagination.PageRequestWrapper;ImportCom.liying.monkey.service.api.RedisService; Public classRedisservicetest {Private StaticApplicationContext context =NULL; Public Static voidMain (string[] args) {context=NewClasspathxmlapplicationcontext ("Spring-monkey.xml", "Spring-redis-cluster.xml"); Redisservice Redisservice= Context.getbean ("Redisserviceimpl", Redisservice.class); intPagenum = 2;//Current Page intPageSize = 5;//size per page intStart = PageSize * (pageNum-1);//because the list element location cardinality in Redis is 0 intEnd = start + pageSize-1; LongTotal = Redisservice.listsize ("UserList"); List<String> dataList = Redisservice.range ("UserList", start, end); Page Page=NewPageimpl (DataList,NewPagerequestwrapper (Pagenum, pageSize), total); System.out.println (Javajsonconvert.java2json (page)); }}
Java Redis Paging query data