File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,8 @@ func New(config ...Config) fiber.Handler {
70
70
// Get entry from pool
71
71
e := manager .get (key )
72
72
73
- // Lock entry and unlock when finished
73
+ // Lock entry
74
74
mux .Lock ()
75
- defer mux .Unlock ()
76
75
77
76
// Get timestamp
78
77
ts := atomic .LoadUint64 (& timestamp )
@@ -105,15 +104,24 @@ func New(config ...Config) fiber.Handler {
105
104
106
105
c .Set (cfg .CacheHeader , cacheHit )
107
106
107
+ mux .Unlock ()
108
+
108
109
// Return response
109
110
return nil
110
111
}
111
112
113
+ // make sure we're not blocking concurrent requests - do unlock
114
+ mux .Unlock ()
115
+
112
116
// Continue stack, return err to Fiber if exist
113
117
if err := c .Next (); err != nil {
114
118
return err
115
119
}
116
120
121
+ // lock entry back and unlock on finish
122
+ mux .Lock ()
123
+ defer mux .Unlock ()
124
+
117
125
// Don't cache response if Next returns true
118
126
if cfg .Next != nil && cfg .Next (c ) {
119
127
c .Set (cfg .CacheHeader , cacheUnreachable )
You can’t perform that action at this time.
0 commit comments