Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caopu16
whatsmars
提交
977c8675
W
whatsmars
项目概览
caopu16
/
whatsmars
与 Fork 源项目一致
Fork自
武汉红喜 / whatsmars
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
977c8675
编写于
1月 22, 2018
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
spring-boot-starter-cache
上级
10ddc538
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
137 addition
and
0 deletion
+137
-0
whatsmars-spring-boot-samples/pom.xml
whatsmars-spring-boot-samples/pom.xml
+1
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/pom.xml
...s-spring-boot-samples/whatsmars-boot-sample-cache/pom.xml
+23
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/AppRunner.java
.../main/java/org/hongxi/whatsmars/boot/cache/AppRunner.java
+30
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/Application.java
...ain/java/org/hongxi/whatsmars/boot/cache/Application.java
+16
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/Book.java
...e/src/main/java/org/hongxi/whatsmars/boot/cache/Book.java
+34
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/BookRepository.java
.../java/org/hongxi/whatsmars/boot/cache/BookRepository.java
+7
-0
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/SimpleBookRepository.java
...org/hongxi/whatsmars/boot/cache/SimpleBookRepository.java
+26
-0
未找到文件。
whatsmars-spring-boot-samples/pom.xml
浏览文件 @
977c8675
...
...
@@ -17,6 +17,7 @@
<module>
whatsmars-boot-sample-aop
</module>
<module>
whatsmars-boot-sample-session
</module>
<module>
whatsmars-boot-sample-logback
</module>
<module>
whatsmars-boot-sample-cache
</module>
</modules>
<!--<properties>
...
...
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/pom.xml
0 → 100644
浏览文件 @
977c8675
<?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"
>
<parent>
<artifactId>
whatsmars-spring-boot-samples
</artifactId>
<groupId>
org.hongxi
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
whatsmars-boot-sample-cache
</artifactId>
<name>
${project.artifactId}
</name>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cache
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/AppRunner.java
0 → 100644
浏览文件 @
977c8675
package
org.hongxi.whatsmars.boot.cache
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
@Component
public
class
AppRunner
implements
CommandLineRunner
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AppRunner
.
class
);
private
final
BookRepository
bookRepository
;
public
AppRunner
(
BookRepository
bookRepository
)
{
this
.
bookRepository
=
bookRepository
;
}
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
logger
.
info
(
".... Fetching books"
);
logger
.
info
(
"isbn-1234 -->"
+
bookRepository
.
getByIsbn
(
"isbn-1234"
));
logger
.
info
(
"isbn-4567 -->"
+
bookRepository
.
getByIsbn
(
"isbn-4567"
));
logger
.
info
(
"isbn-1234 -->"
+
bookRepository
.
getByIsbn
(
"isbn-1234"
));
logger
.
info
(
"isbn-4567 -->"
+
bookRepository
.
getByIsbn
(
"isbn-4567"
));
logger
.
info
(
"isbn-1234 -->"
+
bookRepository
.
getByIsbn
(
"isbn-1234"
));
logger
.
info
(
"isbn-1234 -->"
+
bookRepository
.
getByIsbn
(
"isbn-1234"
));
}
}
\ No newline at end of file
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/Application.java
0 → 100644
浏览文件 @
977c8675
package
org.hongxi.whatsmars.boot.cache
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cache.annotation.EnableCaching
;
/**
* Created by shenhongxi on 2018/1/22.
*/
@EnableCaching
@SpringBootApplication
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
}
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/Book.java
0 → 100644
浏览文件 @
977c8675
package
org.hongxi.whatsmars.boot.cache
;
public
class
Book
{
private
String
isbn
;
private
String
title
;
public
Book
(
String
isbn
,
String
title
)
{
this
.
isbn
=
isbn
;
this
.
title
=
title
;
}
public
String
getIsbn
()
{
return
isbn
;
}
public
void
setIsbn
(
String
isbn
)
{
this
.
isbn
=
isbn
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
@Override
public
String
toString
()
{
return
"Book{"
+
"isbn='"
+
isbn
+
'\''
+
", title='"
+
title
+
'\''
+
'}'
;
}
}
\ No newline at end of file
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/BookRepository.java
0 → 100644
浏览文件 @
977c8675
package
org.hongxi.whatsmars.boot.cache
;
public
interface
BookRepository
{
Book
getByIsbn
(
String
isbn
);
}
\ No newline at end of file
whatsmars-spring-boot-samples/whatsmars-boot-sample-cache/src/main/java/org/hongxi/whatsmars/boot/cache/SimpleBookRepository.java
0 → 100644
浏览文件 @
977c8675
package
org.hongxi.whatsmars.boot.cache
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Component
;
@Component
public
class
SimpleBookRepository
implements
BookRepository
{
@Override
@Cacheable
(
"books"
)
public
Book
getByIsbn
(
String
isbn
)
{
simulateSlowService
();
return
new
Book
(
isbn
,
"Some book"
);
}
// Don't do this at home
private
void
simulateSlowService
()
{
try
{
long
time
=
3000L
;
Thread
.
sleep
(
time
);
}
catch
(
InterruptedException
e
)
{
throw
new
IllegalStateException
(
e
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录