fix item caching

This commit is contained in:
shoopea 2019-08-21 12:23:59 +08:00
parent 38afcbc367
commit e0adbcae87
2 changed files with 6 additions and 1 deletions

5
obj.go
View File

@ -803,10 +803,15 @@ func loadObjItem() error {
c.Code = intl_id c.Code = intl_id
c.Name = name c.Name = name
c.Weight = weight c.Weight = weight
muxObjItem.Lock() muxObjItem.Lock()
cacheObjItem[intl_id] = *c cacheObjItem[intl_id] = *c
cacheObjItem[name] = *c cacheObjItem[name] = *c
muxObjItem.Unlock() muxObjItem.Unlock()
muxObjItemId.Lock()
cacheObjItemId[id] = *c
muxObjItemId.Unlock()
} }
items2, err := db.Query(`SELECT oi.obj_id, oi.intl_id, obn.name, oi.weight FROM obj_item oi, obj_name obn WHERE obn.obj_id = oi.obj_id AND obn.priority > 0;`) items2, err := db.Query(`SELECT oi.obj_id, oi.intl_id, obn.name, oi.weight FROM obj_item oi, obj_name obn WHERE obn.obj_id = oi.obj_id AND obn.priority > 0;`)

2
sql.go
View File

@ -391,7 +391,7 @@ func initDB() {
_, err = db.Exec(`CREATE VIEW obj_item_name_v AS _, err = db.Exec(`CREATE VIEW obj_item_name_v AS
SELECT obi.obj_id SELECT obi.obj_id
,obi.intl_id ,obi.intl_id COLLATE utf8mb4_unicode_ci AS intl_id
,obn.name COLLATE utf8mb4_unicode_ci AS name ,obn.name COLLATE utf8mb4_unicode_ci AS name
,obn.priority ,obn.priority
FROM obj_name obn FROM obj_name obn