From 27b345054608c41307051a20f8f8b0d8c593b5ca Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Wed, 6 Mar 2024 05:50:59 +0000 Subject: [PATCH 1/6] - Added a new client method that takes the name of the response header used to skip caching response - Updated docs to reference the new header --- README.md | 2 ++ cache.go | 56 +++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0d9526f..3b68cb1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ func main() { cache.ClientWithAdapter(memcached), cache.ClientWithTTL(10 * time.Minute), cache.ClientWithRefreshKey("opn"), + cache.ClientWithSkipCacheResponseHeader("x-skip-cache"), ) if err != nil { fmt.Println(err) @@ -77,6 +78,7 @@ import ( cache.ClientWithAdapter(redis.NewAdapter(ringOpt)), cache.ClientWithTTL(10 * time.Minute), cache.ClientWithRefreshKey("opn"), + cache.ClientWithSkipCacheResponseHeader("x-skip-cache"), ) ... diff --git a/cache.go b/cache.go index 0bb2638..288beac 100644 --- a/cache.go +++ b/cache.go @@ -62,11 +62,12 @@ type Response struct { // Client data structure for HTTP cache middleware. type Client struct { - adapter Adapter - ttl time.Duration - refreshKey string - methods []string - writeExpiresHeader bool + adapter Adapter + ttl time.Duration + refreshKey string + skipCacheResponseHeader string + methods []string + writeExpiresHeader bool } // ClientOption is used to set Client settings. @@ -138,27 +139,36 @@ func (c *Client) Middleware(next http.Handler) http.Handler { rec := httptest.NewRecorder() next.ServeHTTP(rec, r) result := rec.Result() + headers := w.Header() statusCode := result.StatusCode value := rec.Body.Bytes() - now := time.Now() - expires := now.Add(c.ttl) - if statusCode < 400 { - response := Response{ - Value: value, - Header: result.Header, - Expiration: expires, - LastAccess: now, - Frequency: 1, + + skipCachingResponse := headers.Get(c.skipCacheResponseHeader) != "" + + if !skipCachingResponse { + + now := time.Now() + expires := now.Add(c.ttl) + if statusCode < 400 { + response := Response{ + Value: value, + Header: result.Header, + Expiration: expires, + LastAccess: now, + Frequency: 1, + } + c.adapter.Set(key, response.Bytes(), response.Expiration) } - c.adapter.Set(key, response.Bytes(), response.Expiration) + if c.writeExpiresHeader { + w.Header().Set("Expires", expires.UTC().Format(http.TimeFormat)) + } + } + for k, v := range result.Header { w.Header().Set(k, strings.Join(v, ",")) } - if c.writeExpiresHeader { - w.Header().Set("Expires", expires.UTC().Format(http.TimeFormat)) - } w.WriteHeader(statusCode) w.Write(value) return @@ -279,6 +289,16 @@ func ClientWithRefreshKey(refreshKey string) ClientOption { } } +// ClientWithSkipCacheResponseHeader sets the name of the response header +// that will be used to ensure a response does not get cached. +// Optional setting. +func ClientWithSkipCacheResponseHeader(headerName string) ClientOption { + return func(c *Client) error { + c.skipCacheResponseHeader = headerName + return nil + } +} + // ClientWithMethods sets the acceptable HTTP methods to be cached. // Optional setting. If not set, default is "GET". func ClientWithMethods(methods []string) ClientOption { From b532746603df4afa61ee831c18990f296819de2f Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Wed, 6 Mar 2024 05:54:28 +0000 Subject: [PATCH 2/6] - Updated module --- README.md | 20 +++++++++---------- .../benchmark/benchmark_comparison_test.go | 4 ++-- .../memory/benchmark/benchmark_gc_overhead.go | 2 +- adapter/memory/memory.go | 2 +- adapter/memory/memory_test.go | 2 +- adapter/redis/redis.go | 2 +- adapter/redis/redis_test.go | 2 +- go.mod | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3b68cb1..cf03154 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # http-cache -[![Build Status](https://travis-ci.org/victorspringer/http-cache.svg?branch=master)](https://travis-ci.org/victorspringer/http-cache) [![Coverage Status](https://coveralls.io/repos/github/victorspringer/http-cache/badge.svg?branch=master)](https://coveralls.io/github/victorspringer/http-cache?branch=master) [![](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat)](https://godoc.org/github.com/victorspringer/http-cache) +[![Build Status](https://travis-ci.org/victorspringer/http-cache.svg?branch=master)](https://travis-ci.org/victorspringer/http-cache) [![Coverage Status](https://coveralls.io/repos/github/victorspringer/http-cache/badge.svg?branch=master)](https://coveralls.io/github/victorspringer/http-cache?branch=master) [![](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat)](https://godoc.org/github.com/ooaklee/http-cache) This is a high performance Golang HTTP middleware for server-side application layer caching, ideal for REST APIs. @@ -10,7 +10,7 @@ The memory adapter minimizes GC overhead to near zero and supports some options ## Getting Started ### Installation -`go get github.com/victorspringer/http-cache` +`go get github.com/ooaklee/http-cache` ### Usage This is an example of use with the memory adapter: @@ -24,8 +24,8 @@ import ( "os" "time" - "github.com/victorspringer/http-cache" - "github.com/victorspringer/http-cache/adapter/memory" + "github.com/ooaklee/http-cache" + "github.com/ooaklee/http-cache/adapter/memory" ) func example(w http.ResponseWriter, r *http.Request) { @@ -63,8 +63,8 @@ func main() { Example of Client initialization with Redis adapter: ```go import ( - "github.com/victorspringer/http-cache" - "github.com/victorspringer/http-cache/adapter/redis" + "github.com/ooaklee/http-cache" + "github.com/ooaklee/http-cache/adapter/redis" ) ... @@ -128,9 +128,9 @@ http-cache memory adapter takes way less GC pause time, that means smaller GC ov - Develop MongoDB adapter ## Godoc Reference -- [http-cache](https://godoc.org/github.com/victorspringer/http-cache) -- [Memory adapter](https://godoc.org/github.com/victorspringer/http-cache/adapter/memory) -- [Redis adapter](https://godoc.org/github.com/victorspringer/http-cache/adapter/redis) +- [http-cache](https://godoc.org/github.com/ooaklee/http-cache) +- [Memory adapter](https://godoc.org/github.com/ooaklee/http-cache/adapter/memory) +- [Redis adapter](https://godoc.org/github.com/ooaklee/http-cache/adapter/redis) ## License -http-cache is released under the [MIT License](https://github.com/victorspringer/http-cache/blob/master/LICENSE). +http-cache is released under the [MIT License](https://github.com/ooaklee/http-cache/blob/master/LICENSE). diff --git a/adapter/memory/benchmark/benchmark_comparison_test.go b/adapter/memory/benchmark/benchmark_comparison_test.go index 9c03788..98b43b2 100644 --- a/adapter/memory/benchmark/benchmark_comparison_test.go +++ b/adapter/memory/benchmark/benchmark_comparison_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/allegro/bigcache" - cache "github.com/victorspringer/http-cache" - "github.com/victorspringer/http-cache/adapter/memory" + cache "github.com/ooaklee/http-cache" + "github.com/ooaklee/http-cache/adapter/memory" ) const maxEntrySize = 256 diff --git a/adapter/memory/benchmark/benchmark_gc_overhead.go b/adapter/memory/benchmark/benchmark_gc_overhead.go index 45bfc36..0a4a519 100644 --- a/adapter/memory/benchmark/benchmark_gc_overhead.go +++ b/adapter/memory/benchmark/benchmark_gc_overhead.go @@ -9,7 +9,7 @@ import ( "time" "github.com/allegro/bigcache" - "github.com/victorspringer/http-cache/adapter/memory" + "github.com/ooaklee/http-cache/adapter/memory" ) const ( diff --git a/adapter/memory/memory.go b/adapter/memory/memory.go index 3458235..72527c1 100644 --- a/adapter/memory/memory.go +++ b/adapter/memory/memory.go @@ -30,7 +30,7 @@ import ( "sync" "time" - cache "github.com/victorspringer/http-cache" + cache "github.com/ooaklee/http-cache" ) // Algorithm is the string type for caching algorithms labels. diff --git a/adapter/memory/memory_test.go b/adapter/memory/memory_test.go index 0cf628a..4e22f0a 100644 --- a/adapter/memory/memory_test.go +++ b/adapter/memory/memory_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - cache "github.com/victorspringer/http-cache" + cache "github.com/ooaklee/http-cache" ) func TestGet(t *testing.T) { diff --git a/adapter/redis/redis.go b/adapter/redis/redis.go index 2181020..0a6fac3 100644 --- a/adapter/redis/redis.go +++ b/adapter/redis/redis.go @@ -29,7 +29,7 @@ import ( redisCache "github.com/go-redis/cache" "github.com/go-redis/redis" - cache "github.com/victorspringer/http-cache" + cache "github.com/ooaklee/http-cache" "github.com/vmihailenco/msgpack" ) diff --git a/adapter/redis/redis_test.go b/adapter/redis/redis_test.go index 635344c..11f2930 100644 --- a/adapter/redis/redis_test.go +++ b/adapter/redis/redis_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/victorspringer/http-cache" + cache "github.com/ooaklee/http-cache" ) var a cache.Adapter diff --git a/go.mod b/go.mod index 52bfde4..8bca161 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/victorspringer/http-cache +module github.com/ooaklee/http-cache go 1.18 From 88f7161c2e08acdf09b2df08efc077b594190298 Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Thu, 7 Mar 2024 01:48:50 +0000 Subject: [PATCH 3/6] - Added logic to allow a user to specify a URI path regex that skips caching for matching requests. --- cache.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cache.go b/cache.go index 288beac..f7426d9 100644 --- a/cache.go +++ b/cache.go @@ -34,6 +34,7 @@ import ( "net/http" "net/http/httptest" "net/url" + "regexp" "sort" "strconv" "strings" @@ -66,6 +67,7 @@ type Client struct { ttl time.Duration refreshKey string skipCacheResponseHeader string + skipCacheUriPathRegex *regexp.Regexp methods []string writeExpiresHeader bool } @@ -89,7 +91,8 @@ type Adapter interface { // Middleware is the HTTP cache middleware handler. func (c *Client) Middleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if c.cacheableMethod(r.Method) { + + if c.cacheableUriPath(r.URL) && c.cacheableMethod(r.Method) { sortURLParams(r.URL) key := generateKey(r.URL.String()) if r.Method == http.MethodPost && r.Body != nil { @@ -186,6 +189,20 @@ func (c *Client) cacheableMethod(method string) bool { return false } +// cacheableUriPath takes the request url and see if it +// matches regex used for skipping cache based on request +// path +func (c *Client) cacheableUriPath(requestUrl *url.URL) bool { + + if c.skipCacheUriPathRegex == nil { + return true + } + + foundMatchingUriPath := c.skipCacheUriPathRegex.FindString(requestUrl.Path) + + return foundMatchingUriPath == "" +} + // BytesToResponse converts bytes array into Response data structure. func BytesToResponse(b []byte) Response { var r Response @@ -299,6 +316,17 @@ func ClientWithSkipCacheResponseHeader(headerName string) ClientOption { } } +// ClientWithSkipCacheUriPathRegex sets the regex that will be +// used to ensure that both request/response of matching path +// is free of cache. +// Optional setting. +func ClientWithSkipCacheUriPathRegex(uriPathRegex *regexp.Regexp) ClientOption { + return func(c *Client) error { + c.skipCacheUriPathRegex = uriPathRegex + return nil + } +} + // ClientWithMethods sets the acceptable HTTP methods to be cached. // Optional setting. If not set, default is "GET". func ClientWithMethods(methods []string) ClientOption { From b36341eb950823dc504d750bca237d974caa1de1 Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Thu, 7 Mar 2024 02:42:25 +0000 Subject: [PATCH 4/6] - Fixed a bug that caused caching even though the correct header was set. --- cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.go b/cache.go index f7426d9..5533660 100644 --- a/cache.go +++ b/cache.go @@ -142,7 +142,7 @@ func (c *Client) Middleware(next http.Handler) http.Handler { rec := httptest.NewRecorder() next.ServeHTTP(rec, r) result := rec.Result() - headers := w.Header() + headers := rec.Header() statusCode := result.StatusCode value := rec.Body.Bytes() From 18826df341f3f6b3cfc8d8c7dc36d972211da209 Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Fri, 8 Mar 2024 02:47:22 +0000 Subject: [PATCH 5/6] - Updated tests to cover new skip ClientOptions (by path regex, by response header) - Updated README to include examples for new ClientOptions --- README.md | 35 ++++++++++++++++- cache.go | 2 +- cache_test.go | 105 ++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 132 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cf03154..f275173 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,14 @@ func main() { os.Exit(1) } + examplePathRegex := regexp.MustCompile(`^/api/v1/.*`) + cacheClient, err := cache.NewClient( cache.ClientWithAdapter(memcached), cache.ClientWithTTL(10 * time.Minute), cache.ClientWithRefreshKey("opn"), - cache.ClientWithSkipCacheResponseHeader("x-skip-cache"), + cache.ClientWithSkipCacheResponseHeader("x-skip-example"), + cache.ClientWithSkipCacheUriPathRegex(examplePathRegex) ) if err != nil { fmt.Println(err) @@ -74,16 +77,44 @@ import ( "server": ":6379", }, } + + examplePathRegex := regexp.MustCompile(`^/api/v1/.*`) + cacheClient, err := cache.NewClient( cache.ClientWithAdapter(redis.NewAdapter(ringOpt)), cache.ClientWithTTL(10 * time.Minute), cache.ClientWithRefreshKey("opn"), - cache.ClientWithSkipCacheResponseHeader("x-skip-cache"), + cache.ClientWithSkipCacheResponseHeader("x-skip-example"), + cache.ClientWithSkipCacheUriPathRegex(examplePathRegex) ) ... ``` +Example of handler func skipping cache using response header +```go +... + cacheClient, err := cache.NewClient( + cache.ClientWithAdapter(memcached), + cache.ClientWithTTL(10 * time.Minute), + cache.ClientWithSkipCacheResponseHeader("x-skip-example"), + ) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + example := func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("X-Skip-Example", "1") + w.Write([]byte(fmt.Sprintf("response value at %s", time.Now().UTC().String()))) + } + + handler := http.HandlerFunc(example) +... +``` + +``` + ## Benchmarks The benchmarks were based on [allegro/bigache](https://github.com/allegro/bigcache) tests and used to compare it with the http-cache memory adapter.
The tests were run using an Intel i5-2410M with 8GB RAM on Arch Linux 64bits.
diff --git a/cache.go b/cache.go index 5533660..8d249b6 100644 --- a/cache.go +++ b/cache.go @@ -142,7 +142,7 @@ func (c *Client) Middleware(next http.Handler) http.Handler { rec := httptest.NewRecorder() next.ServeHTTP(rec, r) result := rec.Result() - headers := rec.Header() + headers := result.Header statusCode := result.StatusCode value := rec.Body.Bytes() diff --git a/cache_test.go b/cache_test.go index 8ebca53..d98e76a 100644 --- a/cache_test.go +++ b/cache_test.go @@ -8,6 +8,7 @@ import ( "net/http/httptest" "net/url" "reflect" + "regexp" "sync" "testing" "time" @@ -48,6 +49,10 @@ func (errReader) Read(p []byte) (n int, err error) { func TestMiddleware(t *testing.T) { counter := 0 httpTestHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if q := r.URL.Query()["set-skip-header"]; len(q) > 0 { + w.Header().Add("X-Skip", "1") + } + w.Write([]byte(fmt.Sprintf("new value %v", counter))) }) @@ -72,28 +77,42 @@ func TestMiddleware(t *testing.T) { }, } + exampleRegex := regexp.MustCompile("^/test-4$") + client, _ := NewClient( ClientWithAdapter(adapter), ClientWithTTL(1*time.Minute), ClientWithRefreshKey("rk"), ClientWithMethods([]string{http.MethodGet, http.MethodPost}), + ClientWithSkipCacheResponseHeader("X-Skip"), + ClientWithSkipCacheUriPathRegex(exampleRegex), ) - handler := client.Middleware(httpTestHandler) + handlers := http.ServeMux{} + handlers.Handle("/test-1", httpTestHandler) + handlers.Handle("/test-2", httpTestHandler) + handlers.Handle("/test-3", httpTestHandler) + handlers.Handle("/test-4", httpTestHandler) + + handler := client.Middleware(&handlers) tests := []struct { - name string - url string - method string - body []byte - wantBody string - wantCode int + name string + url string + method string + body []byte + setSkipHeader bool + skipPath string + wantBody string + wantCode int }{ { "returns cached response", "http://foo.bar/test-1", "GET", nil, + false, + "", "value 1", 200, }, @@ -102,6 +121,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "PUT", nil, + false, + "", "new value 2", 200, }, @@ -110,6 +131,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "GET", nil, + false, + "", "value 2", 200, }, @@ -118,6 +141,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-3?zaz=baz&baz=zaz", "GET", nil, + false, + "", "new value 4", 200, }, @@ -126,6 +151,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-3?baz=zaz&zaz=baz", "GET", nil, + false, + "", "new value 4", 200, }, @@ -134,6 +161,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-3", "GET", nil, + false, + "", "new value 6", 200, }, @@ -142,6 +171,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2?rk=true", "GET", nil, + false, + "", "new value 7", 200, }, @@ -150,6 +181,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "GET", nil, + false, + "", "new value 7", 200, }, @@ -158,6 +191,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "POST", []byte(`{"foo": "bar"}`), + false, + "", "new value 9", 200, }, @@ -166,6 +201,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "POST", []byte(`{"foo": "bar"}`), + false, + "", "new value 9", 200, }, @@ -174,6 +211,8 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "GET", []byte(`{"foo": "bar"}`), + false, + "", "new value 7", 200, }, @@ -182,9 +221,61 @@ func TestMiddleware(t *testing.T) { "http://foo.bar/test-2", "POST", []byte(`{"foo": "bar"}`), + false, + "", "new value 12", 200, }, + { + "skip cached using header - new uncached response", + "http://foo.bar/test-2?set-skip-header=1", + "GET", + nil, + false, + "", + "new value 13", + 200, + }, + { + "skip cached using header - new uncached response (confirm)", + "http://foo.bar/test-2?set-skip-header=1", + "GET", + nil, + false, + "", + "new value 14", + 200, + }, + { + "skip cached using header - confirm didn't change cached value", + "http://foo.bar/test-2", + "GET", + nil, + false, + "", + "new value 7", + 200, + }, + { + "skip cache by regex path - returns new uncached response", + "http://foo.bar/test-4", + "GET", + nil, + false, + "", + "new value 16", + 200, + }, + { + "skip cache by regex path - returns new uncached response (confirm)", + "http://foo.bar/test-4", + "GET", + nil, + false, + "", + "new value 17", + 200, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 70fcb3d14a5feb142b0265da1343d2db0d4e340f Mon Sep 17 00:00:00 2001 From: Leon Silcott Date: Fri, 8 Mar 2024 03:10:33 +0000 Subject: [PATCH 6/6] - Revert mod for PR --- README.md | 20 +++++++++---------- .../benchmark/benchmark_comparison_test.go | 4 ++-- .../memory/benchmark/benchmark_gc_overhead.go | 2 +- adapter/memory/memory.go | 2 +- adapter/memory/memory_test.go | 2 +- adapter/redis/redis.go | 2 +- adapter/redis/redis_test.go | 2 +- go.mod | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f275173..bcdf9c8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # http-cache -[![Build Status](https://travis-ci.org/victorspringer/http-cache.svg?branch=master)](https://travis-ci.org/victorspringer/http-cache) [![Coverage Status](https://coveralls.io/repos/github/victorspringer/http-cache/badge.svg?branch=master)](https://coveralls.io/github/victorspringer/http-cache?branch=master) [![](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat)](https://godoc.org/github.com/ooaklee/http-cache) +[![Build Status](https://travis-ci.org/victorspringer/http-cache.svg?branch=master)](https://travis-ci.org/victorspringer/http-cache) [![Coverage Status](https://coveralls.io/repos/github/victorspringer/http-cache/badge.svg?branch=master)](https://coveralls.io/github/victorspringer/http-cache?branch=master) [![](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat)](https://godoc.org/github.com/victorspringer/http-cache) This is a high performance Golang HTTP middleware for server-side application layer caching, ideal for REST APIs. @@ -10,7 +10,7 @@ The memory adapter minimizes GC overhead to near zero and supports some options ## Getting Started ### Installation -`go get github.com/ooaklee/http-cache` +`go get github.com/victorspringer/http-cache` ### Usage This is an example of use with the memory adapter: @@ -24,8 +24,8 @@ import ( "os" "time" - "github.com/ooaklee/http-cache" - "github.com/ooaklee/http-cache/adapter/memory" + "github.com/victorspringer/http-cache" + "github.com/victorspringer/http-cache/adapter/memory" ) func example(w http.ResponseWriter, r *http.Request) { @@ -66,8 +66,8 @@ func main() { Example of Client initialization with Redis adapter: ```go import ( - "github.com/ooaklee/http-cache" - "github.com/ooaklee/http-cache/adapter/redis" + "github.com/victorspringer/http-cache" + "github.com/victorspringer/http-cache/adapter/redis" ) ... @@ -159,9 +159,9 @@ http-cache memory adapter takes way less GC pause time, that means smaller GC ov - Develop MongoDB adapter ## Godoc Reference -- [http-cache](https://godoc.org/github.com/ooaklee/http-cache) -- [Memory adapter](https://godoc.org/github.com/ooaklee/http-cache/adapter/memory) -- [Redis adapter](https://godoc.org/github.com/ooaklee/http-cache/adapter/redis) +- [http-cache](https://godoc.org/github.com/victorspringer/http-cache) +- [Memory adapter](https://godoc.org/github.com/victorspringer/http-cache/adapter/memory) +- [Redis adapter](https://godoc.org/github.com/victorspringer/http-cache/adapter/redis) ## License -http-cache is released under the [MIT License](https://github.com/ooaklee/http-cache/blob/master/LICENSE). +http-cache is released under the [MIT License](https://github.com/victorspringer/http-cache/blob/master/LICENSE). diff --git a/adapter/memory/benchmark/benchmark_comparison_test.go b/adapter/memory/benchmark/benchmark_comparison_test.go index 98b43b2..9c03788 100644 --- a/adapter/memory/benchmark/benchmark_comparison_test.go +++ b/adapter/memory/benchmark/benchmark_comparison_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/allegro/bigcache" - cache "github.com/ooaklee/http-cache" - "github.com/ooaklee/http-cache/adapter/memory" + cache "github.com/victorspringer/http-cache" + "github.com/victorspringer/http-cache/adapter/memory" ) const maxEntrySize = 256 diff --git a/adapter/memory/benchmark/benchmark_gc_overhead.go b/adapter/memory/benchmark/benchmark_gc_overhead.go index 0a4a519..45bfc36 100644 --- a/adapter/memory/benchmark/benchmark_gc_overhead.go +++ b/adapter/memory/benchmark/benchmark_gc_overhead.go @@ -9,7 +9,7 @@ import ( "time" "github.com/allegro/bigcache" - "github.com/ooaklee/http-cache/adapter/memory" + "github.com/victorspringer/http-cache/adapter/memory" ) const ( diff --git a/adapter/memory/memory.go b/adapter/memory/memory.go index 72527c1..3458235 100644 --- a/adapter/memory/memory.go +++ b/adapter/memory/memory.go @@ -30,7 +30,7 @@ import ( "sync" "time" - cache "github.com/ooaklee/http-cache" + cache "github.com/victorspringer/http-cache" ) // Algorithm is the string type for caching algorithms labels. diff --git a/adapter/memory/memory_test.go b/adapter/memory/memory_test.go index 4e22f0a..0cf628a 100644 --- a/adapter/memory/memory_test.go +++ b/adapter/memory/memory_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - cache "github.com/ooaklee/http-cache" + cache "github.com/victorspringer/http-cache" ) func TestGet(t *testing.T) { diff --git a/adapter/redis/redis.go b/adapter/redis/redis.go index 0a6fac3..2181020 100644 --- a/adapter/redis/redis.go +++ b/adapter/redis/redis.go @@ -29,7 +29,7 @@ import ( redisCache "github.com/go-redis/cache" "github.com/go-redis/redis" - cache "github.com/ooaklee/http-cache" + cache "github.com/victorspringer/http-cache" "github.com/vmihailenco/msgpack" ) diff --git a/adapter/redis/redis_test.go b/adapter/redis/redis_test.go index 11f2930..b098159 100644 --- a/adapter/redis/redis_test.go +++ b/adapter/redis/redis_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - cache "github.com/ooaklee/http-cache" + cache "github.com/victorspringer/http-cache" ) var a cache.Adapter diff --git a/go.mod b/go.mod index 8bca161..52bfde4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ooaklee/http-cache +module github.com/victorspringer/http-cache go 1.18