Skip to content
Snippets Groups Projects
Commit 65308fa7 authored by Travis Ralston's avatar Travis Ralston
Browse files

Small misc cleanup

parent 10f7d207
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ import (
"github.com/turt2live/matrix-media-repo/common/runtime" "github.com/turt2live/matrix-media-repo/common/runtime"
"github.com/turt2live/matrix-media-repo/database" "github.com/turt2live/matrix-media-repo/database"
"github.com/turt2live/matrix-media-repo/errcache" "github.com/turt2live/matrix-media-repo/errcache"
"github.com/turt2live/matrix-media-repo/internal_cache"
"github.com/turt2live/matrix-media-repo/metrics" "github.com/turt2live/matrix-media-repo/metrics"
"github.com/turt2live/matrix-media-repo/plugins" "github.com/turt2live/matrix-media-repo/plugins"
"github.com/turt2live/matrix-media-repo/pool" "github.com/turt2live/matrix-media-repo/pool"
...@@ -134,10 +133,8 @@ func reloadCacheOnChan(reloadChan chan bool) { ...@@ -134,10 +133,8 @@ func reloadCacheOnChan(reloadChan chan bool) {
shouldReload := <-reloadChan shouldReload := <-reloadChan
if shouldReload { if shouldReload {
redislib.Reconnect() redislib.Reconnect()
internal_cache.ReplaceInstance()
} else { } else {
redislib.Stop() redislib.Stop()
internal_cache.Get().Stop()
} }
} }
}() }()
......
...@@ -16,7 +16,7 @@ type templates struct { ...@@ -16,7 +16,7 @@ type templates struct {
var instance *templates var instance *templates
var singletonLock = &sync.Once{} var singletonLock = &sync.Once{}
func GetInstance() *templates { func getInstance() *templates {
if instance == nil { if instance == nil {
singletonLock.Do(func() { singletonLock.Do(func() {
instance = &templates{ instance = &templates{
...@@ -28,7 +28,7 @@ func GetInstance() *templates { ...@@ -28,7 +28,7 @@ func GetInstance() *templates {
} }
func GetTemplate(name string) (*template.Template, error) { func GetTemplate(name string) (*template.Template, error) {
i := GetInstance() i := getInstance()
if v, ok := i.cached[name]; ok { if v, ok := i.cached[name]; ok {
return v, nil return v, nil
} }
......
...@@ -6,17 +6,9 @@ import ( ...@@ -6,17 +6,9 @@ import (
"encoding/hex" "encoding/hex"
) )
func GenerateRandomBytes(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
return nil, err
}
return b, nil
}
func GenerateRandomString(nBytes int) (string, error) { func GenerateRandomString(nBytes int) (string, error) {
b, err := GenerateRandomBytes(nBytes) b := make([]byte, nBytes)
_, err := rand.Read(b)
if err != nil { if err != nil {
return "", err return "", err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment