eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches
https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/
MIT License
2.46k stars 195 forks source link

[Suggestion] Split built-in store implementations out into their own Go modules? #171

Closed jimeh closed 1 year ago

jimeh commented 2 years ago

Having all the different built-in store implementations in the same one Go module means that their dependencies are also pulled in when using eko/gocahce.

If the built-in implementations were moved to their own sub-modules with their own go.mod files, it would enable a much smaller dependency tree narrowed to only what you're actively using.

This should avoid issues like #144 for everyone not actively using the Pegasus store, since they wouldn't be pulling in the pegasus client package as a dependency.

For me this has become a bit of an issue at the moment while trying to use gocache within a custom Traefik plugin. Traefik runs plugins via Yaegi, which means you cannot have anything in the dependency tree that uses the unsafe or syscall packages.

I'm fully aware a change like this would be a major breaking change, but I'd like to maybe get the discussion started.

Also, if it would help, I'd be happy to take a stab at the separation myself and submit a PR.

eko commented 1 year ago

Hi,

New v4.0.0 release have now separated stores into a separated Go module.

So now we have the library that can be imported:

import "github.com/eko/gocache/v4/lib"

and one or multiple cache store(s):

import (
    "github.com/eko/gocache/v4/store/bigcache"
    "github.com/eko/gocache/v4/store/freecache"
    "github.com/eko/gocache/v4/store/go_cache"
    "github.com/eko/gocache/v4/store/memcache"
    "github.com/eko/gocache/v4/store/pegasus"
    "github.com/eko/gocache/v4/store/redis"
    "github.com/eko/gocache/v4/store/rediscluster"
    "github.com/eko/gocache/v4/store/ristretto"
)

I close this issue for now but feel free to reopen if you still have any issue.