MCPcopy Index your code
hub / github.com/dearcode/candy / closeFile

Method closeFile

store/file.go:88–110  ·  view source on GitHub ↗

closeFile 自动关闭长时间不操作的文件.

()

Source from the content-addressed store, hash-verified

86
87// closeFile 自动关闭长时间不操作的文件.
88func (f *fileDB) closeFile() {
89 for ; ; time.Sleep(time.Second) {
90 var names []string
91 now := time.Now()
92 f.RLock()
93 for n, c := range f.cache {
94 if c.name != f.master.name && now.After(c.last) {
95 names = append(names, n)
96 }
97 }
98 f.RUnlock()
99
100 for _, n := range names {
101 f.Lock()
102 c := f.cache[n]
103 delete(f.cache, n)
104 f.Unlock()
105
106 c.file.Close()
107 log.Debugf("close file:%s", c.file.Name())
108 }
109 }
110}
111
112func (f *fileDB) start() error {
113 var err error

Callers 1

startMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected