aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/wfs.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-11 21:12:41 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-11 21:12:41 -0700
commitdf97da25f902912dd527d4aed567408c3ca0f9ae (patch)
tree3e5d4d6bcfb69b3ab869c0b519048943f26e69a1 /weed/filesys/wfs.go
parentc8ca234773e2a0c57c503c1f3464d1ded4edd2df (diff)
downloadseaweedfs-df97da25f902912dd527d4aed567408c3ca0f9ae.tar.xz
seaweedfs-df97da25f902912dd527d4aed567408c3ca0f9ae.zip
mount: add on disk caching
Diffstat (limited to 'weed/filesys/wfs.go')
-rw-r--r--weed/filesys/wfs.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index 49db18b6e..b2f68c030 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -22,18 +22,19 @@ import (
)
type Option struct {
- FilerGrpcAddress string
- GrpcDialOption grpc.DialOption
- FilerMountRootPath string
- Collection string
- Replication string
- TtlSec int32
- ChunkSizeLimit int64
- ChunkCacheCountLimit int64
- DataCenter string
- DirListCacheLimit int64
- EntryCacheTtl time.Duration
- Umask os.FileMode
+ FilerGrpcAddress string
+ GrpcDialOption grpc.DialOption
+ FilerMountRootPath string
+ Collection string
+ Replication string
+ TtlSec int32
+ ChunkSizeLimit int64
+ CacheDir string
+ CacheSizeMB int64
+ DataCenter string
+ DirListCacheLimit int64
+ EntryCacheTtl time.Duration
+ Umask os.FileMode
MountUid uint32
MountGid uint32
@@ -72,6 +73,10 @@ type statsCache struct {
}
func NewSeaweedFileSystem(option *Option) *WFS {
+ chunkCache := chunk_cache.NewChunkCache(256, option.CacheDir, option.CacheSizeMB, 4)
+ util.OnInterrupt(func() {
+ chunkCache.Shutdown()
+ })
wfs := &WFS{
option: option,
listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(option.DirListCacheLimit * 3).ItemsToPrune(100)),
@@ -81,7 +86,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
return make([]byte, option.ChunkSizeLimit)
},
},
- chunkCache: chunk_cache.NewChunkCache(option.ChunkCacheCountLimit),
+ chunkCache: chunkCache,
}
wfs.root = &Dir{name: wfs.option.FilerMountRootPath, wfs: wfs}