-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
23 changed files
with
583 additions
and
173 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,6 @@ | |
.glide/ | ||
/.idea/ | ||
/apolloConfig.json | ||
/application.json | ||
application*.json | ||
/abc1.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"appId": "test", | ||
"cluster": "dev", | ||
"namespaceName": "application", | ||
"namespaceName": "application,abc1", | ||
"ip": "localhost:8888", | ||
"backupConfigPath":"" | ||
} |
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.