Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f11148bc
authored
Jan 05, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert cache.go
parent
7baa204e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
90 deletions
+90
-90
model/cache.go
+90
-90
No files found.
model/cache.go
View file @
f11148bc
...
@@ -14,102 +14,102 @@ import (
...
@@ -14,102 +14,102 @@ import (
//func CacheGetUserGroup(id int) (group string, err error) {
//func CacheGetUserGroup(id int) (group string, err error) {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return GetUserGroup(id)
// return GetUserGroup(id)
// }
// }
// group, err = common.RedisGet(fmt.Sprintf("user_group:%d", id))
// group, err = common.RedisGet(fmt.Sprintf("user_group:%d", id))
// if err != nil {
// if err != nil {
// group, err = GetUserGroup(id)
// group, err = GetUserGroup(id)
// if err != nil {
// if err != nil {
// return "", err
// return "", err
// }
// }
// err = common.RedisSet(fmt.Sprintf("user_group:%d", id), group, time.Duration(constant.UserId2GroupCacheSeconds)*time.Second)
// err = common.RedisSet(fmt.Sprintf("user_group:%d", id), group, time.Duration(constant.UserId2GroupCacheSeconds)*time.Second)
// if err != nil {
// if err != nil {
// common.SysError("Redis set user group error: " + err.Error())
// common.SysError("Redis set user group error: " + err.Error())
// }
// }
// }
// }
// return group, err
// return group, err
//}
//}
//
//
//func CacheGetUsername(id int) (username string, err error) {
//func CacheGetUsername(id int) (username string, err error) {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return GetUsernameById(id)
// return GetUsernameById(id)
// }
// }
// username, err = common.RedisGet(fmt.Sprintf("user_name:%d", id))
// username, err = common.RedisGet(fmt.Sprintf("user_name:%d", id))
// if err != nil {
// if err != nil {
// username, err = GetUsernameById(id)
// username, err = GetUsernameById(id)
// if err != nil {
// if err != nil {
// return "", err
// return "", err
// }
// }
// err = common.RedisSet(fmt.Sprintf("user_name:%d", id), username, time.Duration(constant.UserId2GroupCacheSeconds)*time.Second)
// err = common.RedisSet(fmt.Sprintf("user_name:%d", id), username, time.Duration(constant.UserId2GroupCacheSeconds)*time.Second)
// if err != nil {
// if err != nil {
// common.SysError("Redis set user group error: " + err.Error())
// common.SysError("Redis set user group error: " + err.Error())
// }
// }
// }
// }
// return username, err
// return username, err
//}
//}
//
//
//func CacheGetUserQuota(id int) (quota int, err error) {
//func CacheGetUserQuota(id int) (quota int, err error) {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return GetUserQuota(id)
// return GetUserQuota(id)
// }
// }
// quotaString, err := common.RedisGet(fmt.Sprintf("user_quota:%d", id))
// quotaString, err := common.RedisGet(fmt.Sprintf("user_quota:%d", id))
// if err != nil {
// if err != nil {
// quota, err = GetUserQuota(id)
// quota, err = GetUserQuota(id)
// if err != nil {
// if err != nil {
// return 0, err
// return 0, err
// }
// }
// return quota, nil
// return quota, nil
// }
// }
// quota, err = strconv.Atoi(quotaString)
// quota, err = strconv.Atoi(quotaString)
// return quota, nil
// return quota, nil
//}
//}
//
//
//func CacheUpdateUserQuota(id int) error {
//func CacheUpdateUserQuota(id int) error {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return nil
// return nil
// }
// }
// quota, err := GetUserQuota(id)
// quota, err := GetUserQuota(id)
// if err != nil {
// if err != nil {
// return err
// return err
// }
// }
// return cacheSetUserQuota(id, quota)
// return cacheSetUserQuota(id, quota)
//}
//}
//
//
//func cacheSetUserQuota(id int, quota int) error {
//func cacheSetUserQuota(id int, quota int) error {
// err := common.RedisSet(fmt.Sprintf("user_quota:%d", id), fmt.Sprintf("%d", quota), time.Duration(constant.UserId2QuotaCacheSeconds)*time.Second)
// err := common.RedisSet(fmt.Sprintf("user_quota:%d", id), fmt.Sprintf("%d", quota), time.Duration(constant.UserId2QuotaCacheSeconds)*time.Second)
// return err
// return err
//}
//}
//
//
//func CacheDecreaseUserQuota(id int, quota int) error {
//func CacheDecreaseUserQuota(id int, quota int) error {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return nil
// return nil
// }
// }
// err := common.RedisDecrease(fmt.Sprintf("user_quota:%d", id), int64(quota))
// err := common.RedisDecrease(fmt.Sprintf("user_quota:%d", id), int64(quota))
// return err
// return err
//}
//}
//
//
//func CacheIsUserEnabled(userId int) (bool, error) {
//func CacheIsUserEnabled(userId int) (bool, error) {
// if !common.RedisEnabled {
// if !common.RedisEnabled {
// return IsUserEnabled(userId)
// return IsUserEnabled(userId)
// }
// }
// enabled, err := common.RedisGet(fmt.Sprintf("user_enabled:%d", userId))
// enabled, err := common.RedisGet(fmt.Sprintf("user_enabled:%d", userId))
// if err == nil {
// if err == nil {
// return enabled == "1", nil
// return enabled == "1", nil
// }
// }
//
//
// userEnabled, err := IsUserEnabled(userId)
// userEnabled, err := IsUserEnabled(userId)
// if err != nil {
// if err != nil {
// return false, err
// return false, err
// }
// }
// enabled = "0"
// enabled = "0"
// if userEnabled {
// if userEnabled {
// enabled = "1"
// enabled = "1"
// }
// }
// err = common.RedisSet(fmt.Sprintf("user_enabled:%d", userId), enabled, time.Duration(constant.UserId2StatusCacheSeconds)*time.Second)
// err = common.RedisSet(fmt.Sprintf("user_enabled:%d", userId), enabled, time.Duration(constant.UserId2StatusCacheSeconds)*time.Second)
// if err != nil {
// if err != nil {
// common.SysError("Redis set user enabled error: " + err.Error())
// common.SysError("Redis set user enabled error: " + err.Error())
// }
// }
// return userEnabled, err
// return userEnabled, err
//}
//}
var
group2model2channels
map
[
string
]
map
[
string
][]
*
Channel
var
group2model2channels
map
[
string
]
map
[
string
][]
*
Channel
var
channelsIDM
map
[
int
]
*
Channel
var
channelsIDM
map
[
int
]
*
Channel
...
@@ -181,7 +181,7 @@ func CacheGetRandomSatisfiedChannel(group string, model string, retry int) (*Cha
...
@@ -181,7 +181,7 @@ func CacheGetRandomSatisfiedChannel(group string, model string, retry int) (*Cha
}
}
// if memory cache is disabled, get channel directly from database
// if memory cache is disabled, get channel directly from database
if
(
!
common
.
MemoryCacheEnabled
)
{
if
!
common
.
MemoryCacheEnabled
{
return
GetRandomSatisfiedChannel
(
group
,
model
,
retry
)
return
GetRandomSatisfiedChannel
(
group
,
model
,
retry
)
}
}
channelSyncLock
.
RLock
()
channelSyncLock
.
RLock
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment