@@ -14,19 +14,23 @@ func getRecord(
14
14
get func (ctx context.Context , record dal.Record ) error ,
15
15
) (err error ) {
16
16
key := record .Key ()
17
- if ! isCacheable (key ) {
17
+ if ! isCacheable (key ) { // If the record is not cacheable, we just get it from the database
18
18
return get (ctx , record )
19
19
}
20
20
mk := key .String ()
21
21
var item * memcache.Item
22
22
if item , err = memcache .Get (ctx , mk ); err == nil {
23
- record .SetError (nil )
23
+ record .SetError (nil ) // We must indicate we are going to access data for unmarshalling
24
24
if err = json .Unmarshal (item .Value , record .Data ()); err == nil {
25
25
if Debugf != nil {
26
26
Debugf (ctx , "memcache4dalgo.getRecord: hit %s" , mk )
27
27
}
28
28
return
29
+ } else if Debugf != nil { // Ignore the error and try to get the record from the database
30
+ Debugf (ctx , "memcache4dalgo.getRecord: failed to unmarshal value from received from memcache ny key=%s: %v" , mk , err )
29
31
}
32
+ } else if Debugf != nil { // Ignore the error and try to get the record from the database
33
+ Debugf (ctx , "memcache4dalgo.getRecord: memcache.Get(key=%s) returned error: %v" , mk , err )
30
34
}
31
35
if err = get (ctx , record ); err == nil {
32
36
if err = setRecordToCache (ctx , record , "getRecord" ); err != nil {
@@ -42,7 +46,7 @@ func setRecordToCache(ctx context.Context, record dal.Record, caller string) (er
42
46
mk := record .Key ().String ()
43
47
_ = memcache .Set (ctx , & memcache.Item {Value : value , Key : mk })
44
48
if Debugf != nil {
45
- Debugf (ctx , "memcache4dalgo.%s: miss & set %s" , caller , mk )
49
+ Debugf (ctx , "memcache4dalgo.%s(): set record to cache with key= %s" , caller , mk )
46
50
}
47
51
}
48
52
return
0 commit comments