Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
discovery
Commits
934e2179
Commit
934e2179
authored
Jul 06, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guava缓存换成Caffeine缓存
parent
82ee86ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
12 deletions
+18
-12
discovery-plugin-framework/pom.xml
+5
-0
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/cache/PluginCache.java
+6
-12
pom.xml
+7
-0
No files found.
discovery-plugin-framework/pom.xml
View file @
934e2179
...
@@ -31,6 +31,11 @@
...
@@ -31,6 +31,11 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter
</artifactId>
<artifactId>
spring-cloud-starter
</artifactId>
</dependency>
</dependency>
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/cache/PluginCache.java
View file @
934e2179
...
@@ -9,22 +9,20 @@ package com.nepxion.discovery.plugin.framework.cache;
...
@@ -9,22 +9,20 @@ package com.nepxion.discovery.plugin.framework.cache;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.g
oogle.common.cache.CacheBuil
der
;
import
com.g
ithub.benmanes.caffeine.cache.CacheLoa
der
;
import
com.g
oogle.common.cache.CacheLoader
;
import
com.g
ithub.benmanes.caffeine.cache.Caffeine
;
import
com.g
oogle.common
.cache.LoadingCache
;
import
com.g
ithub.benmanes.caffeine
.cache.LoadingCache
;
public
class
PluginCache
{
public
class
PluginCache
{
private
LoadingCache
<
String
,
String
>
loadingCache
;
private
LoadingCache
<
String
,
String
>
loadingCache
;
public
PluginCache
()
{
public
PluginCache
()
{
loadingCache
=
CacheBuilder
.
newBuilder
()
loadingCache
=
Caffeine
.
newBuilder
()
.
concurrencyLevel
(
8
)
.
expireAfterWrite
(
365
*
10
,
TimeUnit
.
DAYS
)
.
expireAfterWrite
(
365
*
100
,
TimeUnit
.
DAYS
)
.
initialCapacity
(
10
)
.
initialCapacity
(
10
)
.
maximumSize
(
100
)
.
maximumSize
(
100
)
.
recordStats
()
.
recordStats
()
...
@@ -43,11 +41,7 @@ public class PluginCache {
...
@@ -43,11 +41,7 @@ public class PluginCache {
}
}
public
String
get
(
String
key
)
{
public
String
get
(
String
key
)
{
try
{
return
loadingCache
.
get
(
key
);
return
loadingCache
.
get
(
key
);
}
catch
(
ExecutionException
e
)
{
return
StringUtils
.
EMPTY
;
}
}
}
public
boolean
clear
(
String
key
)
{
public
boolean
clear
(
String
key
)
{
...
...
pom.xml
View file @
934e2179
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
<commons.collections4.version>
4.1
</commons.collections4.version>
<commons.collections4.version>
4.1
</commons.collections4.version>
<commons.io.version>
2.5
</commons.io.version>
<commons.io.version>
2.5
</commons.io.version>
<dom4j.version>
1.6.1
</dom4j.version>
<dom4j.version>
1.6.1
</dom4j.version>
<caffeine.version>
2.6.2
</caffeine.version>
<swagger.version>
2.7.0
</swagger.version>
<swagger.version>
2.7.0
</swagger.version>
<spring.cloud.version>
Edgware.SR4
</spring.cloud.version>
<spring.cloud.version>
Edgware.SR4
</spring.cloud.version>
<!-- <spring.cloud.version>Dalston.SR5</spring.cloud.version> -->
<!-- <spring.cloud.version>Dalston.SR5</spring.cloud.version> -->
...
@@ -130,6 +131,12 @@
...
@@ -130,6 +131,12 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
<version>
${caffeine.version}
</version>
</dependency>
<dependency>
<groupId>
dom4j
</groupId>
<groupId>
dom4j
</groupId>
<artifactId>
dom4j
</artifactId>
<artifactId>
dom4j
</artifactId>
<version>
${dom4j.version}
</version>
<version>
${dom4j.version}
</version>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment