提交 192f66a5 编写于 作者: X xiongchun

重构框架核心,封装缓存starter:pangu-framework-cache-spring-boot-starter

上级 4b075ae0
......@@ -24,7 +24,10 @@
3. 分页查询和手工映复杂SQL的方法
- **pangu-examples-cache-layering**
1. 如何使用两级缓存(本地缓存+Redis集中缓存)。
1. 如何使用两级缓存(本地缓存+Redis集中缓存)
- **pangu-examples-cache-layering**
1. 如何使用原生的一级缓存RedisTemplate API
- **pangu-examples-dubbo-api**
1. 开发Dubbo服务时接口文件和POJO相关类的打包模块
......
......@@ -28,10 +28,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@Slf4j
@EnableLayeringCache
@SpringBootApplication
public class CachePanguApplication {
public class LayeringCachePanguApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(CachePanguApplication.class).run(args);
PanGuApplicationBuilder.init(LayeringCachePanguApplication.class).run(args);
}
}
\ No newline at end of file
......@@ -16,13 +16,6 @@
#
spring.application.name=pangu-examples-cache-layering
# spring-cache \u4E00\u7EA7\u7F13\u5B58
spring.redis.host=localhost
spring.redis.database=1
spring.redis.port=6379
spring.redis.password=
# layering-cache \u591A\u7EA7\u7F13\u5B58
# \u7F13\u5B58\u76D1\u63A7\u7EDF\u8BA1\u5F00\u5173 \u7F3A\u7701true
layering-cache.stats=false
......
/target/
/bin/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
#### :mushroom: 本范例演示功能
1. 如何使用原生的一级缓存RedisTemplate API。
**更多开发指南请参考盘古平台相关文档说明。**
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-parent</artifactId>
<version>5.0.7</version>
<relativePath/>
</parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-examples-cache-single</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-cache-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gitee.pulanos.pangu.showcases.cache.single;
import com.gitee.pulanos.pangu.framework.starter.PanGuApplicationBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author xiongchun
*/
@Slf4j
@SpringBootApplication
public class SimpleCachePanguApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(SimpleCachePanguApplication.class).run(args);
}
}
\ No newline at end of file
package com.gitee.pulanos.pangu.showcases.cache.single.pojo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @author xiongchun
*/
@Data
@Accessors(chain = true)
public class UserVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 流水号
*/
private Long id;
/**
* 姓名
*/
private String name;
/**
* 生日
*/
private Date birthday;
/**
* 年龄
*/
private Integer age;
/**
* 创建时间
*/
private Date gmtCreate;
}
package com.gitee.pulanos.pangu.showcases.cache.single.service;
import com.alibaba.fastjson.JSON;
import com.gitee.pulanos.pangu.showcases.cache.single.pojo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
/**
* 基于API的一级缓存演示
*
* @author xiongchun
*/
@Slf4j
@Component
public class ApiBasedDemoService {
@Autowired
private RedisTemplate<String, String> redisTemplate;
public void testRedisCache() {
String key = "user:1";
UserVO userVO = new UserVO().setId(1L).setName("钱学森");
redisTemplate.opsForValue().set(key, JSON.toJSONString(userVO));
String userJson = redisTemplate.opsForValue().get(key);
log.info(userJson);
}
}
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spring.application.name=pangu-examples-cache-single
# spring-cache \u4E00\u7EA7\u7F13\u5B58
spring.redis.host=localhost
spring.redis.database=1
spring.redis.port=6379
spring.redis.password=
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
\ No newline at end of file
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spring.profiles.active=${spring.profiles.active:dev}
\ No newline at end of file
package com.gitee.pulanos.pangu.showcases.cache.single.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApiBasedDemoServiceTest {
@Autowired
private ApiBasedDemoService apiBasedDemoService;
@Test
public void testRedisCache() {
apiBasedDemoService.testRedisCache();
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@
<module>pangu-examples-config-local</module>
<module>pangu-examples-log-dynamic</module>
<module>pangu-examples-crud</module>
<module>pangu-examples-cache-single</module>
<module>pangu-examples-cache-layering</module>
<module>pangu-examples-dubbo-api</module>
<module>pangu-examples-dubbo-service</module>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册