Is there a way to see if value returned is retrned from Cache or Db #274
Amorganskate
started this conversation in
General
Replies: 1 comment 2 replies
-
Hi @Amorganskate no, there's not, at least not built in. This is because the return type of the What you may do is use an approach like this: var fromCache = true;
var person = cache.GetOrSet<Person>(
"person:1",
(ctx, ct) => {
var res = GetPersonFromDb(1);
fromCache = false; // THIS HERE
return res;
},
...
);
if (fromCache) {
// HERE YOU'LL KNOW THAT PERSON CAME FROM THE CACHE
// ...
} Hope this helps, let me know! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to see if value returned is retrned from Cache or Db?
Might end up running into a hard requirement to return a response header letting client know if cache was hit or not
Beta Was this translation helpful? Give feedback.
All reactions