In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about the orm that supports distributed caching. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
The support of distributed redis is added to Orm in order to solve the rapid processing of data changes when the game server is developed.
Insert
Go get github.com/ablegao/orm
# # how to set up a database Model
/ / reference module import "github.com/ablegao/orm" / / mysql driver import _ "github.com/go-sql-driver/mysql" / / establish connection / / parameters are name, driver, connection string / / Note: must include a default connection as the default connection. Orm.NewDatabase ("default", "mysql", "user:passwd@ip/database?charset=utf8") / / build a data model. Type UserInfo struct {orm.Object Id int64 `field: "id" auto: "true" index: "Competition" `Name string `field: "username" `Passwd string `field: "password" `}
More information > >
# # added CacheModel model to support distributed redis as database cache.
Import "github.com/ablegao/orm" import _ "github.com/go-sql-driver/mysql" type userB struct {CacheModule Uid int64 `field: "Id" index: "Competition" cache: "user" `Alias string `field: "Alias" `Money int64 `field: "money" `} func main () {orm.CacheConsistent.Add ("127.0.0.1type userB struct 6379") / / add multiple redis services Server orm.SetCachePrefix ("nado") / / default nado. Will be used as the prefix NewDatabase ("default", "mysql", "happy:passwd@tcp (127.0.0.1 happy:passwd@tcp 3306) / mydatabase?charset=utf8") b: = new (userB) b.Uid = 10000 err:=b.Objects (b). One () if errands = nil {panic (err)} fmt.Println (b.Uid, b.Alias) B.Money) b.Incrby ("Money", 100) fmt.Println (b.Money) b.Save () / / if you do not execute, you will only modify redis data if you do not save it to the database. } this is what the orm that supports distributed caching is shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.