使用MMAP提升缓存读取性能

This commit is contained in:
GoEdgeLab
2024-03-29 19:30:12 +08:00
parent dc5d828bc3
commit 9e9ec24bd2
5 changed files with 42 additions and 6 deletions

View File

@@ -41,6 +41,7 @@ func (this *CreatePopupAction) RunPost(params struct {
MaxSizeJSON []byte
FetchTimeoutJSON []byte
SyncCompressionCache bool
EnableMMAP bool
Description string
IsOn bool
@@ -97,6 +98,7 @@ func (this *CreatePopupAction) RunPost(params struct {
OpenFileCache: openFileCacheConfig,
EnableSendfile: params.FileEnableSendfile,
MinFreeSize: minFreeSize,
EnableMMAP: params.EnableMMAP,
}
case serverconfigs.CachePolicyStorageMemory:
options = &serverconfigs.HTTPMemoryCacheStorage{}

View File

@@ -40,13 +40,23 @@ func (this *UpdateAction) RunGet(params struct {
return
}
// fix min free size
if cachePolicy.Type == serverconfigs.CachePolicyStorageFile && cachePolicy.Options != nil {
_, ok := cachePolicy.Options["minFreeSize"]
if !ok {
cachePolicy.Options["minFreeSize"] = &shared.SizeCapacity{
Count: 0,
Unit: shared.SizeCapacityUnitGB,
// fix min free size
{
_, ok := cachePolicy.Options["minFreeSize"]
if !ok {
cachePolicy.Options["minFreeSize"] = &shared.SizeCapacity{
Count: 0,
Unit: shared.SizeCapacityUnitGB,
}
}
}
// fix enableMMAP
{
_, ok := cachePolicy.Options["enableMMAP"]
if !ok {
cachePolicy.Options["enableMMAP"] = true
}
}
}
@@ -77,6 +87,8 @@ func (this *UpdateAction) RunPost(params struct {
SyncCompressionCache bool
FetchTimeoutJSON []byte
EnableMMAP bool
Description string
IsOn bool
@@ -137,6 +149,7 @@ func (this *UpdateAction) RunPost(params struct {
OpenFileCache: openFileCacheConfig,
EnableSendfile: params.FileEnableSendfile,
MinFreeSize: minFreeSize,
EnableMMAP: params.EnableMMAP,
}
case serverconfigs.CachePolicyStorageMemory:
options = &serverconfigs.HTTPMemoryCacheStorage{}