LFUDA changes #47
3
go.mod
|
@ -5,6 +5,7 @@ replace github.com/btcsuite/btcd => github.com/lbryio/lbrycrd.go v0.0.0-20200203
|
||||||
require (
|
require (
|
||||||
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect
|
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect
|
||||||
github.com/aws/aws-sdk-go v1.16.11
|
github.com/aws/aws-sdk-go v1.16.11
|
||||||
|
github.com/bparli/lfuda-go v0.3.0
|
||||||
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3
|
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
|
@ -25,7 +26,7 @@ require (
|
||||||
github.com/lbryio/lbry.go v1.1.2 // indirect
|
github.com/lbryio/lbry.go v1.1.2 // indirect
|
||||||
github.com/lbryio/lbry.go/v2 v2.6.1-0.20200901175808-73382bb02128
|
github.com/lbryio/lbry.go/v2 v2.6.1-0.20200901175808-73382bb02128
|
||||||
github.com/lbryio/types v0.0.0-20191228214437-05a22073b4ec
|
github.com/lbryio/types v0.0.0-20191228214437-05a22073b4ec
|
||||||
github.com/lucas-clemente/quic-go v0.19.1
|
github.com/lucas-clemente/quic-go v0.19.2
|
||||||
github.com/phayes/freeport v0.0.0-20171002185219-e27662a4a9d6
|
github.com/phayes/freeport v0.0.0-20171002185219-e27662a4a9d6
|
||||||
github.com/prometheus/client_golang v0.9.2
|
github.com/prometheus/client_golang v0.9.2
|
||||||
github.com/sirupsen/logrus v1.4.2
|
github.com/sirupsen/logrus v1.4.2
|
||||||
|
|
4
go.sum
|
@ -25,6 +25,8 @@ github.com/aws/aws-sdk-go v1.16.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||||
|
github.com/bparli/lfuda-go v0.3.0 h1:b6qPjEb0BN006oQnj2nuGfz94yY3iYo0bmuFM079tQg=
|
||||||
|
github.com/bparli/lfuda-go v0.3.0/go.mod h1:BR5a9lwlqRqnPhU3F5ojFK3VhTKg8iFVtJJKgZBQhAo=
|
||||||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||||
|
@ -223,6 +225,8 @@ github.com/lbryio/types v0.0.0-20191228214437-05a22073b4ec/go.mod h1:CG3wsDv5BiV
|
||||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lucas-clemente/quic-go v0.19.1 h1:J9TkQJGJVOR3UmGhd4zdVYwKSA0EoXbLRf15uQJ6gT4=
|
github.com/lucas-clemente/quic-go v0.19.1 h1:J9TkQJGJVOR3UmGhd4zdVYwKSA0EoXbLRf15uQJ6gT4=
|
||||||
github.com/lucas-clemente/quic-go v0.19.1/go.mod h1:ZUygOqIoai0ASXXLJ92LTnKdbqh9MHCLTX6Nr1jUrK0=
|
github.com/lucas-clemente/quic-go v0.19.1/go.mod h1:ZUygOqIoai0ASXXLJ92LTnKdbqh9MHCLTX6Nr1jUrK0=
|
||||||
|
github.com/lucas-clemente/quic-go v0.19.2 h1:w8BBYUx5Z+kNpeaOeQW/KzcNsKWhh4O6PeQhb0nURPg=
|
||||||
|
github.com/lucas-clemente/quic-go v0.19.2/go.mod h1:ZUygOqIoai0ASXXLJ92LTnKdbqh9MHCLTX6Nr1jUrK0=
|
||||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||||
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
|
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
|
||||||
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
|
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
|
||||||
|
|
|
@ -58,6 +58,7 @@ func TestCachingStore_CacheMiss(t *testing.T) {
|
||||||
if !bytes.Equal(b, res) {
|
if !bytes.Equal(b, res) {
|
||||||
t.Errorf("expected Get() to return %s, got %s", string(b), string(res))
|
t.Errorf("expected Get() to return %s, got %s", string(b), string(res))
|
||||||
}
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond) //storing to cache is done async so let's give it some time
|
||||||
|
|||||||
|
|
||||||
has, err := cache.Has(hash)
|
has, err := cache.Has(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
118
store/lfuda.go
Normal file
|
@ -0,0 +1,118 @@
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
package store
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
import (
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
"github.com/bparli/lfuda-go"
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
"github.com/lbryio/lbry.go/v2/stream"
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
"github.com/lbryio/reflector.go/internal/metrics"
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// LRUStore adds a max cache size and LRU eviction to a BlobStore
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
type LFUDAStore struct {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// underlying store
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
if this is very similar to LRUStore, maybe we need a generic EvictionStrategy struct of some sort if this is very similar to LRUStore, maybe we need a generic EvictionStrategy struct of some sort
|
|||||||
|
store BlobStore
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// lfuda implementation
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
lfuda *lfuda.Cache
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// NewLRUStore initialize a new LRUStore
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func NewLFUDAStore(component string, store BlobStore, maxSize float64) *LFUDAStore {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
lfuda := lfuda.NewGDSFWithEvict(maxSize, func(key interface{}, value interface{}) {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
metrics.CacheLRUEvictCount.With(metrics.CacheLabels(store.Name(), component)).Inc()
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
_ = store.Delete(key.(string)) // TODO: log this error. may happen if underlying entry is gone but cache entry still there
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
})
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
lfuda.Age()
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l := &LFUDAStore{
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
store: store,
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
lfuda: lfuda,
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
go func() {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if lstr, ok := store.(lister); ok {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
err := l.loadExisting(lstr, int(maxSize/2000000.0))
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if err != nil {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
panic(err) // TODO: what should happen here? panic? return nil? just keep going?
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}()
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return l
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
const nameLFUDA = "lfuda"
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
var fakeTrue = []byte{'t'}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Name is the cache type name
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) Name() string { return nameLFUDA }
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Has returns whether the blob is in the store, without updating the recent-ness.
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) Has(hash string) (bool, error) {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return l.lfuda.Contains(hash), nil
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Get returns the blob or an error if the blob doesn't exist.
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) Get(hash string) (stream.Blob, error) {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
_, has := l.lfuda.Get(hash)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if !has {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return nil, errors.Err(ErrBlobNotFound)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
blob, err := l.store.Get(hash)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if errors.Is(err, ErrBlobNotFound) {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Blob disappeared from underlying store
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l.lfuda.Remove(hash)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return blob, err
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
👍 for the comment :+1: for the comment
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Put stores the blob. Following LFUDA rules it's not guaranteed that a SET will store the value!!!
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) Put(hash string, blob stream.Blob) error {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
err := l.store.Put(hash, blob)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if err != nil {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return err
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l.lfuda.Set(hash, fakeTrue)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return nil
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// PutSD stores the sd blob
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) PutSD(hash string, blob stream.Blob) error {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
err := l.store.PutSD(hash, blob)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
why are Put and PutSD implemented differently? why are Put and PutSD implemented differently?
|
|||||||
|
if err != nil {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return err
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l.lfuda.Set(hash, fakeTrue)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return nil
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Delete deletes the blob from the store
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) Delete(hash string) error {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
err := l.store.Delete(hash)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if err != nil {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return err
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// This must come after store.Delete()
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// Remove triggers onEvict function, which also tries to delete blob from store
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// We need to delete it manually first so any errors can be propagated up
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l.lfuda.Remove(hash)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return nil
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
// loadExisting imports existing blobs from the underlying store into the LRU cache
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
func (l *LFUDAStore) loadExisting(store lister, maxItems int) error {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
existing, err := store.list()
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if err != nil {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return err
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
stuff like this makes me even more confident that LRU and LFUDA should be less copy-pasted and more the same object with an eviction strategy selector stuff like this makes me even more confident that LRU and LFUDA should be less copy-pasted and more the same object with an eviction strategy selector
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
added := 0
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
for _, h := range existing {
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
l.lfuda.Set(h, fakeTrue)
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
added++
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
if maxItems > 0 && added >= maxItems { // underlying cache is bigger than LRU cache
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
break
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
return nil
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
|||||||
|
}
|
||||||
seems weird to do this. why not an actual seems weird to do this. why not an actual `bool`, or an empty struct?
the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM. I since worked with the developer of the library to address this so i believe we can go back to using a bool the reason I did this was because the library wasn't treating a bool as a 1byte type and it would waste a lot of RAM.
I since worked with the developer of the library to address this so i believe we can go back to using a bool
|
139
store/lfuda_test.go
Normal file
|
@ -0,0 +1,139 @@
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
package store
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
import (
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"io/ioutil"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"os"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"reflect"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"testing"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"time"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
log "github.com/sirupsen/logrus"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"github.com/stretchr/testify/assert"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"github.com/stretchr/testify/require"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
const cacheMaxSize = 3
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
func getTestLFUDAStore() (*LFUDAStore, *MemStore) {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
m := NewMemStore()
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
return NewLFUDAStore("test", m, cacheMaxSize), m
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
func TestFUDAStore_Eviction(t *testing.T) {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda, mem := getTestLFUDAStore()
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
b := []byte("x")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err := lfuda.Put("one", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("two", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("three", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("four", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("five", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("five", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("four", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Put("two", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
check the blob value too? check the blob value too?
|
|||||||
|
_, err = lfuda.Get("five")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
_, err = lfuda.Get("four")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
_, err = lfuda.Get("two")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, cacheMaxBlobs, len(mem.Debug()))
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
for k, v := range map[string]bool{
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"one": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"two": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"three": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"four": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"five": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"six": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
} {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
has, err := lfuda.Has(k)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, v, has)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda.Get("two") // touch so it stays in cache
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda.Get("five") // touch so it stays in cache
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda.Put("six", b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, cacheMaxBlobs, len(mem.Debug()))
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
keys := lfuda.lfuda.Keys()
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
log.Infof("%+v", keys)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
for k, v := range map[string]bool{
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"one": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"two": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"three": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"four": false,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"five": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
"six": true,
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
} {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
has, err := lfuda.Has(k)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, v, has)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Delete("six")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Delete("five")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = lfuda.Delete("two")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, 0, len(mem.Debug()))
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
func TestFUDAStore_UnderlyingBlobMissing(t *testing.T) {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda, mem := getTestLFUDAStore()
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
hash := "hash"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
b := []byte("this is a blob of stuff")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err := lfuda.Put(hash, b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = mem.Delete(hash)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
// hash still exists in lru
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.True(t, lfuda.lfuda.Contains(hash))
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
blob, err := lfuda.Get(hash)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Nil(t, blob)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.True(t, errors.Is(err, ErrBlobNotFound), "expected (%s) %s, got (%s) %s",
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
reflect.TypeOf(ErrBlobNotFound).String(), ErrBlobNotFound.Error(),
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
reflect.TypeOf(err).String(), err.Error())
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
// lru.Get() removes hash if underlying store doesn't have it
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.False(t, lfuda.lfuda.Contains(hash))
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
func TestFUDAStore_loadExisting(t *testing.T) {
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
tmpDir, err := ioutil.TempDir("", "reflector_test_*")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
d := NewDiskStore(tmpDir, 2)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
hash := "hash"
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
b := []byte("this is a blob of stuff")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
err = d.Put(hash, b)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
existing, err := d.list()
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.Equal(t, 1, len(existing), "blob should exist in cache")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.Equal(t, hash, existing[0])
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
lfuda := NewLFUDAStore("test", d, 3) // lru should load existing blobs when it's created
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
time.Sleep(100 * time.Millisecond) // async load so let's wait...
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
has, err := lfuda.Has(hash)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
require.NoError(t, err)
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
assert.True(t, has, "hash should be loaded from disk store but it's not")
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|||||||
|
}
|
||||||
use use `t.Log()` insteade
ah right, this can actually be removed. it was a debug statement ah right, this can actually be removed. it was a debug statement
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/v2/extras/errors"
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
||||||
|
|
||||||
|
@ -114,7 +115,8 @@ func TestLRUStore_loadExisting(t *testing.T) {
|
||||||
require.Equal(t, 1, len(existing), "blob should exist in cache")
|
require.Equal(t, 1, len(existing), "blob should exist in cache")
|
||||||
assert.Equal(t, hash, existing[0])
|
assert.Equal(t, hash, existing[0])
|
||||||
|
|
||||||
lru := NewLRUStore("test", d, 3) // lru should load existing blobs when it's created
|
lru := NewLRUStore("test", d, 3) // lru should load existing blobs when it's created
|
||||||
|
time.Sleep(100 * time.Millisecond) // async load so let's wait...
|
||||||
has, err := lru.Has(hash)
|
has, err := lru.Has(hash)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, has, "hash should be loaded from disk store but it's not")
|
assert.True(t, has, "hash should be loaded from disk store but it's not")
|
||||||
|
|
need a way to do these sync or async. at the very least, an option for the cache. ideally, some process of notifying when writes finish.