mirror of
https://github.com/elyby/chrly.git
synced 2025-01-03 18:51:49 +05:30
Отныне мы не используем пул соединений для редиса (Revert, прогнал тесты, убедился, что только хуже)
This reverts commit 915c465224
.
This commit is contained in:
parent
915c465224
commit
283f4e0e3f
@ -20,12 +20,12 @@ type SkinItem struct {
|
|||||||
|
|
||||||
func (s *SkinItem) Save() {
|
func (s *SkinItem) Save() {
|
||||||
str, _ := json.Marshal(s)
|
str, _ := json.Marshal(s)
|
||||||
services.RedisPool.Cmd("SET", tools.BuildKey(s.Nickname), str)
|
services.Redis.Cmd("SET", tools.BuildKey(s.Nickname), str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindRecord(username string) (SkinItem, error) {
|
func FindRecord(username string) (SkinItem, error) {
|
||||||
var record SkinItem;
|
var record SkinItem;
|
||||||
result, err := services.RedisPool.Cmd("GET", tools.BuildKey(username)).Str();
|
result, err := services.Redis.Cmd("GET", tools.BuildKey(username)).Str();
|
||||||
if (err == nil) {
|
if (err == nil) {
|
||||||
decodeErr := json.Unmarshal([]byte(result), &record)
|
decodeErr := json.Unmarshal([]byte(result), &record)
|
||||||
if (decodeErr != nil) {
|
if (decodeErr != nil) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mediocregopher/radix.v2/pool"
|
"github.com/mediocregopher/radix.v2/redis"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
var RedisPool *pool.Pool
|
var Redis *redis.Client
|
||||||
|
|
||||||
var Router *mux.Router
|
var Router *mux.Router
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/mediocregopher/radix.v2/pool"
|
"github.com/mediocregopher/radix.v2/redis"
|
||||||
|
|
||||||
"elyby/minecraft-skinsystem/lib/routes"
|
"elyby/minecraft-skinsystem/lib/routes"
|
||||||
"elyby/minecraft-skinsystem/lib/services"
|
"elyby/minecraft-skinsystem/lib/services"
|
||||||
@ -15,7 +15,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
pool, redisErr := pool.New("tcp", "redis:6379", 10)
|
client, redisErr := redis.Dial("tcp", "redis:6379")
|
||||||
if redisErr != nil {
|
if redisErr != nil {
|
||||||
log.Fatal("Redis unavailable")
|
log.Fatal("Redis unavailable")
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ func main() {
|
|||||||
apiRouter := router.PathPrefix("/api").Subrouter()
|
apiRouter := router.PathPrefix("/api").Subrouter()
|
||||||
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
|
apiRouter.HandleFunc("/user/{username}/skin", routes.SetSkin).Methods("POST")
|
||||||
|
|
||||||
services.RedisPool = pool
|
services.Redis = client
|
||||||
services.Router = router
|
services.Router = router
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(":80", router))
|
log.Fatal(http.ListenAndServe(":80", router))
|
||||||
|
Loading…
Reference in New Issue
Block a user