Using memcache for session data?

Hi! I’m currently on Gogs 0.12.3, running on top of Ubuntu Linux 20.04.1 LTS (focal).

I wonder if there is a way to get the session data written to memcache; I see that you can use Redis both for session data as well as for the cache. I’m not running Redis on this server but tend to use memcache extensively. It would be nice to get the session data there as well.

I see that sessions are part of the Context, which, in turn, uses many other components, including go-macaron/session, which can use memcache as a backend.

However, on gogs/internal/conf/conf.go, only is included (file and memory are built-in without the need of another library). I’m assuming that there might be some reason for having been left out by the developers on purpose? (e.g. it might interfere with other code, or was found to be too unreliable, etc.)

Thanks in advance!


– Gwyn

Actually, I now noticed that memcache is not even used for the cache… or at least that was the case in 2016!

I’m not even sure if I’m configuring the cache correctly:

; The cache adapter, either "memory", "redis", or "memcache".
ADAPTER = memcache
; For "memory" only, GC interval in seconds.
; For "redis" and "memcache", connection host address:
; - redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
; - memcache: ``
HOST = ``

I’ve checked, and memcache is indeed running correctly (other applications are using it). I’ve also tried HOST = But in both cases, Gogs shows the following on /admin/config:

In other words, it always displays Host (not set) — no matter what I place on the configuration file.

I’ve tried to follow the code on GitHub, but it seems to me that all cache management is simply pushed to go-macaron's own caching system. Thus, as far as I can see, all that Gogs does is to read the configuration file, check if this item exists, and push it to go-macaron, which allegedly does something with it and returns a cache object. But somehow the correct value or parameter for the memcache host is not being read (or gets discarded…) and therefore Gogs will not really be talking to the memcache server (I’m assuming that it’s basically not caching anything…).

So, what am I doing wrong? I’m almost tempted to give Redis a try, just to see what happens… :wink: