forked from apolloconfig/agollo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
468 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
.glide/ | ||
/.idea/ | ||
/apolloConfig.json | ||
/application.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package agcache | ||
|
||
import "github.com/coocood/freecache" | ||
|
||
//CacheInterface 自定义缓存组件接口 | ||
type CacheInterface interface { | ||
Set(key, value []byte, expireSeconds int) (err error) | ||
|
||
EntryCount() (entryCount int64) | ||
|
||
Get(key []byte) (value []byte, err error) | ||
|
||
Del(key []byte) (affected bool) | ||
|
||
NewIterator() *freecache.Iterator | ||
|
||
TTL(key []byte) (timeLeft uint32, err error) | ||
|
||
Clear() | ||
} | ||
|
||
const ( | ||
//50m | ||
apolloConfigCacheSize = 50 * 1024 * 1024 | ||
|
||
//1 minute | ||
configCacheExpireTime = 120 | ||
) | ||
|
||
//CacheFactory 缓存组件工厂接口 | ||
type CacheFactory interface { | ||
//Create 创建缓存组件 | ||
Create() CacheInterface | ||
} | ||
|
||
//DefaultCacheFactory 构造默认缓存组件工厂类 | ||
type DefaultCacheFactory struct { | ||
|
||
} | ||
|
||
//Create 创建默认缓存组件 | ||
func (d *DefaultCacheFactory) Create()CacheInterface { | ||
return freecache.NewCache(apolloConfigCacheSize) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.