缓存文件实现Sendfile

This commit is contained in:
GoEdgeLab
2022-04-04 19:46:12 +08:00
parent 1373517c57
commit 64e619e6e3
8 changed files with 79 additions and 13 deletions

View File

@@ -32,6 +32,7 @@ func (this *CreatePopupAction) RunPost(params struct {
FileDir string
FileMemoryCapacityJSON []byte
FileOpenFileCacheMax int
FileEnableSendfile bool
CapacityJSON []byte
MaxSizeJSON []byte
@@ -77,7 +78,8 @@ func (this *CreatePopupAction) RunPost(params struct {
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
Capacity: memoryCapacity,
},
OpenFileCache: openFileCacheConfig,
OpenFileCache: openFileCacheConfig,
EnableSendfile: params.FileEnableSendfile,
}
case serverconfigs.CachePolicyStorageMemory:
options = &serverconfigs.HTTPMemoryCacheStorage{}

View File

@@ -26,13 +26,13 @@ func (this *UpdateAction) RunGet(params struct {
this.ErrorPage(err)
return
}
configJSON := configResp.HttpCachePolicyJSON
var configJSON = configResp.HttpCachePolicyJSON
if len(configJSON) == 0 {
this.NotFound("cachePolicy", params.CachePolicyId)
return
}
cachePolicy := &serverconfigs.HTTPCachePolicy{}
var cachePolicy = &serverconfigs.HTTPCachePolicy{}
err = json.Unmarshal(configJSON, cachePolicy)
if err != nil {
this.ErrorPage(err)
@@ -56,6 +56,7 @@ func (this *UpdateAction) RunPost(params struct {
FileDir string
FileMemoryCapacityJSON []byte
FileOpenFileCacheMax int
FileEnableSendfile bool
CapacityJSON []byte
MaxSizeJSON []byte
@@ -106,7 +107,8 @@ func (this *UpdateAction) RunPost(params struct {
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
Capacity: memoryCapacity,
},
OpenFileCache: openFileCacheConfig,
OpenFileCache: openFileCacheConfig,
EnableSendfile: params.FileEnableSendfile,
}
case serverconfigs.CachePolicyStorageMemory:
options = &serverconfigs.HTTPMemoryCacheStorage{}