This commit is contained in:
wanglei 2025-10-29 20:39:49 +08:00
commit 33e03e3258
3 changed files with 25 additions and 56 deletions

View File

@ -11,6 +11,7 @@ return {
time_zone = "+8:00", -- UTC + 8
REDIS_PREFIX = 'Auth:',
-- 配置redis数据库连接
REDIS = {
HOST = "127.0.0.1", -- redis host
@ -25,5 +26,10 @@ return {
USERNAME = "postgres",
PASSWORD = "1qaz2wsx", -- postgres password
DATABASE = "postgres",
CHARSET = 'utf8',
POOL_TIMEOUT = 1000, -- postgresql pool timeout
POOL_SIZE = 100, -- postgresql pool size
TIMEOUT = 1000, -- postgresql timeout
}
}

View File

@ -1,37 +0,0 @@
local env = require('config')
return {
redis_prefix = 'Auth:',
redis = {
host = env.REDIS.HOST,
port = env.REDIS.PORT,
password = env.REDIS.PASSWORD
},
postgres = {
host = env.POSTGRES.HOST,
port = env.POSTGRES.PORT,
user = env.POSTGRES.USERNAME,
password = env.POSTGRES.PASSWORD,
database = env.POSTGRES.DATABASE,
write = { -- postgresql write database
host = env.POSTGRES.HOST,
port = env.POSTGRES.PORT,
user = env.POSTGRES.USERNAME,
password = env.POSTGRES.PASSWORD,
database = env.POSTGRES.DATABASE
},
read = { -- postgresql read database
host = env.POSTGRES.HOST,
port = env.POSTGRES.PORT,
user = env.POSTGRES.USERNAME,
password = env.POSTGRES.PASSWORD,
database = env.POSTGRES.DATABASE
},
charset = 'utf8',
pool_timeout = 1000, -- postgresql pool timeout
pool_size = 100, -- postgresql pool size
timeout = 1000, -- postgresql timeout
},
}

View File

@ -1,5 +1,5 @@
local Database = require('share.database')
local dbconf = require("config.database")
local conf = require("config")
local helpers = require('share.helpers')
local implode = helpers.implode
@ -12,28 +12,28 @@ local WRITE = 'WRITE'
local READ = 'READ'
local database_write = Database:new({
host = dbconf.postgres.write.host,
port = dbconf.postgres.write.port,
user = dbconf.postgres.write.user,
password = dbconf.postgres.write.password,
database = dbconf.postgres.write.database,
--charset = dbconf.postgres.charset,
--timeout = dbconf.postgres.timeout,
db_pool_timeout = dbconf.postgres.pool_timeout,
db_pool_size = dbconf.postgres.pool_size,
host = conf.POSTGRES.host,
port = conf.POSTGRES.port,
user = conf.POSTGRES.user,
password = conf.POSTGRES.password,
database = conf.POSTGRES.database,
--charset = conf.POSTGRES.charset,
--timeout = conf.POSTGRES.timeout,
db_pool_timeout = conf.POSTGRES.pool_timeout,
db_pool_size = conf.POSTGRES.pool_size,
db_type = WRITE
})
local database_read = Database:new({
host = dbconf.postgres.read.host,
port = dbconf.postgres.read.port,
user = dbconf.postgres.read.user,
password = dbconf.postgres.read.password,
database = dbconf.postgres.read.database,
--charset = dbconf.postgres.charset,
--timeout = dbconf.postgres.timeout,
db_pool_timeout = dbconf.postgres.pool_timeout,
db_pool_size = dbconf.postgres.pool_size,
host = conf.POSTGRES.host,
port = conf.POSTGRES.port,
user = conf.POSTGRES.user,
password = conf.POSTGRES.password,
database = conf.POSTGRES.database,
--charset = conf.POSTGRES.charset,
--timeout = conf.POSTGRES.timeout,
db_pool_timeout = conf.POSTGRES.pool_timeout,
db_pool_size = conf.POSTGRES.pool_size,
db_type = READ
})