@@ -95,7 +95,15 @@ func NewSession(payload NewSessionPayload) *Session {
9595
9696 if ! payload .IgnoreCache {
9797 if err := cache .Store (sessionKey (s .ID ), s , time .Minute * 30 ); err != nil {
98- log .Error ("set session info to cache failed" , "error" , err )
98+ log .ErrorContext (
99+ s .RequestContext (),
100+ "set session info to cache failed" ,
101+ "session_id" , s .ID ,
102+ "cache_key" , sessionKey (s .ID ),
103+ "cluster_id" , s .ClusterID ,
104+ "plugin_unique_identifier" , s .PluginUniqueIdentifier .String (),
105+ "error" , err ,
106+ )
99107 }
100108 }
101109
@@ -139,12 +147,32 @@ type DeleteSessionPayload struct {
139147
140148func DeleteSession (payload DeleteSessionPayload ) {
141149 sessionLock .Lock ()
150+ session := sessions [payload .ID ]
142151 delete (sessions , payload .ID )
143152 sessionLock .Unlock ()
144153
145154 if ! payload .IgnoreCache {
146- if _ , err := cache .Del (sessionKey (payload .ID )); err != nil {
147- log .Error ("delete session info from cache failed" , "error" , err )
155+ cacheKey := sessionKey (payload .ID )
156+ if _ , err := cache .Del (cacheKey ); err != nil {
157+ if session != nil {
158+ log .ErrorContext (
159+ session .RequestContext (),
160+ "delete session info from cache failed" ,
161+ "session_id" , payload .ID ,
162+ "cache_key" , cacheKey ,
163+ "cluster_id" , session .ClusterID ,
164+ "plugin_unique_identifier" , session .PluginUniqueIdentifier .String (),
165+ "error" , err ,
166+ )
167+ } else {
168+ log .ErrorContext (
169+ context .Background (),
170+ "delete session info from cache failed" ,
171+ "session_id" , payload .ID ,
172+ "cache_key" , cacheKey ,
173+ "error" , err ,
174+ )
175+ }
148176 }
149177 }
150178}
0 commit comments