]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add function to wrap squirrel.Cache as storage.ClientImpl
authorMatt Joiner <anacrolix@gmail.com>
Thu, 26 Aug 2021 01:20:37 +0000 (11:20 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 26 Aug 2021 01:20:37 +0000 (11:20 +1000)
storage/sqlite/direct.go

index fe5b27016a62267182b8327187eadff17d2177e7..b36867fac3ce3457a0c9be2ad46b2c80ab5849d2 100644 (file)
@@ -26,6 +26,13 @@ func NewDirectStorage(opts NewDirectStorageOpts) (_ storage.ClientImplCloser, er
        }, nil
 }
 
+func NewWrappingClient(cache *squirrel.Cache) storage.ClientImpl {
+       return &client{
+               cache,
+               cache.GetCapacity,
+       }
+}
+
 type client struct {
        *squirrel.Cache
        capacity func() *int64