The Cacher interface would have an additional first argument of a context.Context obtained from the DB Statement.
Motivation
It would be idiomatic to pass a context to a blocking cache adapter such as Redis.
I wish to explicitly mark queries as being cacheable. For this I am adding a value to the context object; queries without this value will be uncached. I appreciate this is a controversial pattern but it is the simplest way to achieve this without support within Gorm itself. This is perhaps a separate issue, but having the context argument at least provides a workaround.
Describe the feature
The
Cacher
interface would have an additional first argument of acontext.Context
obtained from the DBStatement
.Motivation
I appreciate this is a breaking change. For now I have forked this library to add this argument to the
Cacher
. See https://github.com/mgdigital/gorm-cache/pull/1/filesRelated Issues