Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cache.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package cache

/*
MIT License

Expand All @@ -22,8 +24,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package cache

import (
"bufio"
"bytes"
Expand Down Expand Up @@ -116,6 +116,7 @@ type Adapter interface {
func (client *Client) Middleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Request().URL.ForceQuery = false
if !client.isAllowedPathToCache(c.Request().URL.String()) {
next(c)
return nil
Expand All @@ -142,7 +143,6 @@ func (client *Client) Middleware() echo.MiddlewareFunc {
c.Request().URL.RawQuery = params.Encode()
key = generateKey(c.Request().URL.String())

client.adapter.Release(key)
} else {
b, ok := client.adapter.Get(key)
response := BytesToResponse(b)
Expand All @@ -160,8 +160,6 @@ func (client *Client) Middleware() echo.MiddlewareFunc {
c.Response().Write(response.Value)
return nil
}

client.adapter.Release(key)
}
}

Expand All @@ -185,6 +183,7 @@ func (client *Client) Middleware() echo.MiddlewareFunc {
LastAccess: now,
Frequency: 1,
}
client.adapter.Release(key)
client.adapter.Set(key, response.Bytes(), response.Expiration)
}
//for k, v := range writer.Header() {
Expand Down