gin-contrib / gin-contrib/cache
Cache in InMemoryStore is broken
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 456
- Forks
- 100
- Avg merge
- 2h 16m
- Merged PRs (30d)
- 2
Description
You may find the source code at https://github.com/fzlee/GoldenFly. it's a personal blog
In all, the following code demonstrates the way I use this middleware
// main.go, init memory store
store := persistence.NewInMemoryStore(5 * time.Second)
// page/router.go, creating cached view
router.GET("/articles-sidebar/", cache.CachePage(store, time.Second * 10, PageSideBarView))
You may reproduce this issue by the following steps:
- goto http://ifconfiger.com
- open web developer tool
- refresh this web page for several times
there are chances we could get an invalid JSON response from the server like this:

seems the memory block which we used to keep response cache is modified by other requests.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the GoldenFly source at the InMemoryStore implementation and trace how CachePage reads and writes response data. Reproduce the issue by repeatedly refreshing the example page with developer tools open, then inspect concurrent requests and the cached response path. Done means repeated refreshes no longer produce invalid JSON responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100