diff options
Diffstat (limited to 'modules/globallock/globallock.go')
-rw-r--r-- | modules/globallock/globallock.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/globallock/globallock.go b/modules/globallock/globallock.go index aa53557729..24e91881bb 100644 --- a/modules/globallock/globallock.go +++ b/modules/globallock/globallock.go @@ -6,14 +6,22 @@ package globallock import ( "context" "sync" + + "code.gitea.io/gitea/modules/setting" ) var ( defaultLocker Locker initOnce sync.Once initFunc = func() { - // TODO: read the setting and initialize the default locker. - // Before implementing this, don't use it. + switch setting.GlobalLock.ServiceType { + case "redis": + defaultLocker = NewRedisLocker(setting.GlobalLock.ServiceConnStr) + case "memory": + fallthrough + default: + defaultLocker = NewMemoryLocker() + } } // define initFunc as a variable to make it possible to change it in tests ) |