victorspringer / http-cache

High performance Golang HTTP middleware for server-side application layer caching, ideal for REST APIs
https://godoc.org/github.com/victorspringer/http-cache
MIT License
339 stars 63 forks source link

Questions #16

Closed andre-meneses-fivestars closed 1 year ago

andre-meneses-fivestars commented 1 year ago

Hey @victorspringer, if you can help with these two questions, I'd appreciate.

// Initialize the router
router := mux.NewRouter().StrictSlash(true)

//Memory Cache code
memcached, err := memory.NewAdapter(
  memory.AdapterWithAlgorithm(memory.LRU),
  memory.AdapterWithCapacity(10000000),
)
if err != nil {
  fmt.Println(err)
  os.Exit(1)
}

cacheClient, err := cache.NewClient(
  cache.ClientWithAdapter(memcached),
  cache.ClientWithTTL(30*time.Second),
  cache.ClientWithRefreshKey("opn"),
)
if err != nil {
  fmt.Println(err)
  os.Exit(1)
}
router.Use(cacheClient.Middleware)

Thank you!

victorspringer commented 1 year ago

Hi André, yes, the memory package uses in-memory storage. The configuration looks good 👍

meneses-pt commented 1 year ago

Thank you for your response @victorspringer. I'm using this on a live project: https://goals.zone/ The Backend project can be found on: https://github.com/meneses-pt/go_als.zone

Great work here