Your Question

We're adding Redis as a caching layer to our gorm setup. Is there a suggested way to implement write-through caching? I saw some older discussions about this from 2016 where the resolution was:

I don't do GORM level caching. Not worth the hassle of trying to modify gorm.

Is this still the case? I also found: https://github.com/liyuan1125/gorm-cache but given it's stars and popularity I am wary of using it directly in production.

What is the general advice here? Is the expectation to have the caching layers above gorm or built into it?

The document you expected this should be explained

https://gorm.io/docs/

Expected answer

Just looking for general advice and how others have gone about it.

Comment From: black-06

Gorm does not have a built-in cache.

The cache plugins I know of are: - https://github.com/liyuan1125/gorm-cache , it appears in GORM Open Sources - https://github.com/8treenet/gcache , It has more stars

Comment From: a631807682

We will not introduce caching in gorm, but support users to support it through plugins or other forms. The cache mechanism mainly depends on the business, and it is meaningless to implement a cache like mysql query cache (it has been removed in mysql 8.0) Like @black-06 said, you can use cache plugin, gorm also provides https://github.com/go-gorm/caches plugin