]> git.lizzy.rs Git - go-fscache.git/blob - cachelock.go
Replace obsolete lock package
[go-fscache.git] / cachelock.go
1 package fscache
2
3 import (
4         "github.com/gofrs/flock"
5 )
6
7 // Locks the file that backs the given key.
8 //
9 // If the call is successful, it's the caller's responsibility to call Unlock on the returned lock.
10 func (cd *CacheDir) Lock(key ...CacheKey) (*flock.Flock, error) {
11         l := flock.New(cd.cachePath(key...))
12         return l, l.Lock()
13 }