Skip to content

Commit

Permalink
update to reflect changes in go-cache 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Dec 12, 2019
1 parent bd5db38 commit 5a22480
Show file tree
Hide file tree
Showing 240 changed files with 377 additions and 62,121 deletions.
53 changes: 31 additions & 22 deletions blob.go
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
package blob
package cache

import (
"bufio"
"bytes"
"context"
"github.com/aaronland/gocloud-blob-bucket"
"github.com/whosonfirst/go-cache"
wof_cache "github.com/whosonfirst/go-cache"
"gocloud.dev/blob"
"io"
"io/ioutil"
"sync/atomic"
)

type BlobCache struct {
cache.Cache
TTL int64
wof_cache.Cache
TTL int64
bucket *blob.Bucket
hits int64
misses int64
sets int64
evictions int64
}

func NewBlobCacheWithDSN(bucket_dsn string) (cache.Cache, error) {

func init() {
ctx := context.Background()
c := NewBlobCache()

bucket, err := bucket.OpenBucket(ctx, bucket_dsn)
for _, scheme := range blob.DefaultURLMux().BucketSchemes() {
wof_cache.RegisterCache(ctx, scheme, c)
}
}

if err != nil {
return nil, err
func NewBlobCache() wof_cache.Cache {

c := &BlobCache{
TTL: 0,
misses: 0,
sets: 0,
evictions: 0,
}

return NewBlobCacheWithBucket(bucket)
return c
}

func NewBlobCacheWithBucket(bucket *blob.Bucket) (cache.Cache, error) {
func (c *BlobCache) Open(ctx context.Context, uri string) error {

c := BlobCache{
TTL: 0,
bucket: bucket,
hits: 0,
misses: 0,
sets: 0,
evictions: 0,
bucket, err := blob.OpenBucket(ctx, uri)

if err != nil {
return err
}

return &c, nil
c.bucket = bucket
return nil
}

func (c *BlobCache) Close(ctx context.Context) error {
return nil
}

func (c *BlobCache) Name() string {
Expand Down Expand Up @@ -143,12 +152,12 @@ func (c *BlobCache) SizeWithContext(ctx context.Context) int64 {
for {

select {
case <- ctx.Done():
case <-ctx.Done():
return -1
default:
//
}

obj, err := iter.Next(ctx)

if err == io.EOF {
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/whosonfirst/go-cache-blob
go 1.12

require (
github.com/aaronland/gocloud-blob-bucket v0.0.1
github.com/whosonfirst/go-cache v0.0.1
gocloud.dev v0.16.0
github.com/whosonfirst/go-cache v0.0.2
gocloud.dev v0.18.0
)
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcig
github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU=
github.com/Azure/azure-pipeline-go v0.1.8/go.mod h1:XA1kFWRVhSK+KNFiOhfv83Fv8L9achrP7OxIzeTn1Yg=
github.com/Azure/azure-pipeline-go v0.1.9/go.mod h1:XA1kFWRVhSK+KNFiOhfv83Fv8L9achrP7OxIzeTn1Yg=
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
github.com/Azure/azure-sdk-for-go v29.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v30.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-service-bus-go v0.9.1/go.mod h1:yzBx6/BUGfjfeqbRZny9AQIbIe3AcV9WZbAdpkoXOa0=
github.com/Azure/azure-storage-blob-go v0.6.0/go.mod h1:oGfmITT1V6x//CswqY2gtAHND+xIP64/qL7a5QJix0Y=
github.com/Azure/azure-storage-blob-go v0.8.0/go.mod h1:lPI3aLPpuLTeUwh1sViKXFxwl2B6teiRqI0deQUvsw0=
github.com/Azure/go-autorest v12.0.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190605020000-c4ba1fdf4d36/go.mod h1:aJ4qN3TfrelA6NZ6AXsXRfmEVaYin3EDbSPJrKS8OXo=
github.com/aaronland/go-aws-session v0.0.3 h1:lTOw1ifDKD7QgM8sWAOcFdlUIhs1JmcbMlfZv5GxYDc=
github.com/aaronland/go-aws-session v0.0.3/go.mod h1:nc4r+JFoGM6sop/lTspmUDcRIUW/V2NWs9Nd6jQWk90=
github.com/aaronland/go-roster v0.0.1 h1:r1l4n1HfWvEtOXZvhfXX0Won9Xf6QJsigdUdzOtuy/M=
github.com/aaronland/go-roster v0.0.1/go.mod h1:AcovpxlG1XxJxX2Fjqlm63fEIBhCjEIBV4lP87FZDmI=
github.com/aaronland/go-string v0.1.0 h1:HU6OHmEpN2m9b5SOIwU6HoOq87Fvemj/0g6DTp8yzpk=
github.com/aaronland/go-string v0.1.0/go.mod h1:2aMIWdTqk63jZsaLLy+p9dsB1MDRqx4sHYoLtkwyYUo=
github.com/aaronland/gocloud-blob-bucket v0.0.1 h1:GbjBsKpSa5SIzIENRBPO3HFwo+tqXEPELg6WwUT2oPA=
Expand Down Expand Up @@ -78,6 +82,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand All @@ -93,6 +98,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/whosonfirst/go-cache v0.0.1 h1:PEp+sGpgS7oF5EMb1WnG7S79SVHbxXSgOMrOP6/guRM=
github.com/whosonfirst/go-cache v0.0.1/go.mod h1:pEvjE3Fi9EOsaod6oRVvkTRSrBV4d3NJqvMBuHBCv7Y=
github.com/whosonfirst/go-cache v0.0.2 h1:O6DxFeSkHPSCxmXSmsTX5tXCY8m/FStEPgglR/Z8q5M=
github.com/whosonfirst/go-cache v0.0.2/go.mod h1:SUK9m5/Dh2WvYGCtlu1Uxo1h+6VUaRra1QHaPSOF+gI=
github.com/whosonfirst/go-whosonfirst-cache v0.1.0 h1:ryWTsHj7gAEjwHC/WjsjROpFflsz3SCa7W9Qnk4EU7k=
github.com/whosonfirst/go-whosonfirst-cache v0.1.0/go.mod h1:P5Tx34j2M50qX/kTfXY516apwGzJGkFSBYQI7TGArKw=
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
Expand All @@ -101,6 +108,8 @@ go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
gocloud.dev v0.16.0 h1:hWeaQWxamGerwsU7B9xSWvUjx0p7TwG8fcHro2TzbbM=
gocloud.dev v0.16.0/go.mod h1:xWGXD8t7bEhqPIuyAUFyXV9qHn+PvEY2F2GKPh7i/O0=
gocloud.dev v0.18.0 h1:HX6uFZYZs9tUP87jzoWgB8dl4ihsRpiAsBDKTthiApY=
gocloud.dev v0.18.0/go.mod h1:lhLOb91+9tKB8RnNlsx+weJGEd0AHM94huK1bmrhPwM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -157,6 +166,8 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.6.0/go.mod h1:btoxGiFvQNVUZQ8W08zLtrVS08CNpINPEfxXxgJL1Q4=
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/aaronland/go-aws-session/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions vendor/github.com/aaronland/go-aws-session/README.md

This file was deleted.

70 changes: 0 additions & 70 deletions vendor/github.com/aaronland/go-aws-session/config.go

This file was deleted.

24 changes: 0 additions & 24 deletions vendor/github.com/aaronland/go-aws-session/credentials.go

This file was deleted.

81 changes: 0 additions & 81 deletions vendor/github.com/aaronland/go-aws-session/env.go

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/github.com/aaronland/go-aws-session/errors.go

This file was deleted.

10 changes: 0 additions & 10 deletions vendor/github.com/aaronland/go-aws-session/go.mod

This file was deleted.

Loading

0 comments on commit 5a22480

Please sign in to comment.