Install DB Cache and Set Up Network

Game database schema for DB cache

The database schema for DB cache can be configured as desired by the user.

However, the following rules must be followed.

  • The RootUUID, OwnerUUID, and UUID fields must be present.

  • When RootUUID, OwnerUUUID, and UUID are specified as Combination PK, it adversely affects search using indexing. Therefore, creating and using each index helps improve performance.

  • Among the above fields, the RootUUID and OwnerUUID are designated as Non-Unique Index, and the UUID is designated as Primary Key.

  • The above field must be in varchar(38) format in MySQL and uniqueidentifier format in MSSQL.

  • The names of the Root table and Child table must not be duplicated.

  • The stored procedure used by the DB cache client and server are automatically added to the game database schema; do not modify or remove them.

Example script for adding 3 required indexes

ALTER TABLE dbo.Gamer ADD CONSTRAINT
 
PK_Gamer PRIMARY KEY CLUSTERED
 
(
 
UUID
 
) WITH( IGNORE_DUP_KEY = OFF) ON [PRIMARY]
 
 
 
CREATE INDEX IX_Gamer_OwnerUUID ON dbo.Gamer
 
(
 
OwnerUUID
 
) WITH( IGNORE_DUP_KEY = OFF) ON [PRIMARY]
 
 
 
CREATE INDEX IX_Gamer_RootUUID ON dbo.Gamer
 
(
 
RootUUID
 
) WITH( IGNORE_DUP_KEY = OFF) ON [PRIMARY]

Prepare the DB cache server

After creating the database schema, you need to create a DB cache server instance. Only one instance of type Proud.CDbCacheServer2 is sufficient between each game server.

InstanceDescription

Proud.CDbCacheServer2.New

Creating an instance

Proud.CDbCacheServer2.Start

Execution

  • The connection string to connect to the DB instance is in the form of an ADO connection string, which you can see in the sample.

  • The authentication key of the DB cache server is the data sent by the DB cache client to identify the connection on the DB cache server.

  • When calling Proud.CDbCacheServer2.Start, Proud.CDbCacheServer2StartParameter.m_tableNames must contain the table names defined by the user.

  • While Proud.CDbCacheServer2.Start is running, sp_Get<tablename>Data, sp_Remove<tablename>Data, and sp_Add<tablename>Data are automatically created.

Prepare the DB cache client

Each game server (authentication server, game zone server, lobby server, etc.) must run Proud.CDbCacheClient2.New to create a client instance of type Proud.CDbCacheClient2.

After creation, you must attempt to connect to the DB cache server via Proud.CDbCacheClient2.Connect. The connection attempt is asynchronous and Proud.IDbCacheClientDelegate2.OnJoinDbCacheServerComplete is called when the connection succeeds or fails. The DB cache client internally uses Proud.CLanClient, but since it is a thread pooling method, there is no separate FrameMove.

To disconnect from the DB cache server, destroy the Proud.CDbCacheClient2 object or call Proud.CDbCacheClient2.Disconnect. At this time, the DB cache client calls Proud.IDbCacheClientDelegate2.OnLeaveDbCacheServer.

Last updated