> For the complete documentation index, see [llms.txt](https://docs.proudnet.com/proudnet.eng/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.proudnet.com/proudnet.eng/proudnet/db_system/db_cache_ver2/using/usage.md).

# Utilization of DB Cache

## Mixing ADO with the ProudNet DB cache system

The DB cache system and ADO Wrapper API can be used interchangeably. However, when users directly handle tables that are exclusively accessed by the [**DB Cache Server and Client**](/proudnet.eng/proudnet/db_system/db_cache_ver2/server_client.md), the following must be taken care of.

> **Reading tables**
>
> The data cached in <mark style="color:orange;">Proud.CDbCacheServer2</mark> may not have been flushed to the DBMS yet, so the data information you get may be older than the actual state.\
> \
> **Writing tables**\ <mark style="color:orange;">Proud.CDbCacheServer2</mark> writes to these tables intermittently, so if you write something to them, it might overwrite the data that <mark style="color:orange;">Proud.CDbCacheServer2</mark> writes to them. Therefore, it is not recommended to write to these tables.

{% hint style="success" %}
**Reference**\
[**Direct DB access to data covered by the DB cache**](/proudnet.eng/proudnet/db_system/db_cache_ver2/theory.md#direct-db-access-to-data-covered-by-the-db-cache)
{% endhint %}

## Adjusting DB cache disposition

Shortening the interval between writing cached DB information to the DBMS reduces the risk of losing unsaved data due to an abnormal shutdown of the DB cache server at the expense of DBMS performance.

The related method is <mark style="color:orange;">Proud.CDbCacheServer2.SetDbmsWriteIntervalMs</mark>.

When the data is used and unloaded by the DB cache client, the gamer information remains in the DB cache server's memory, and after a period of time, it is also destroyed in the DB cache server's memory.

If you make this time period shorter, the memory used by the DB cache server will increase, but the load on the DBMS will be less because the DBMS will fetch data less often.

The related method is <mark style="color:orange;">Proud.CDbCacheServer2.SetUnloadedDataHibernateDurationMs</mark>.

## Loading a partial DB cache

It is possible that only one of a gamer's characters needs to be loaded. Partial loading is possible using the features of the ProudNet DB cache system.<br>

> **Examples**\
> \* RootTable is the Gamer, CharacterInfo table.\
> \* ChildTable is a Hero under Gamer, and an Item under CharacterInfo.\
> \* At least one user-defined field in Hero points to one field in CharacterInfo.

Using the [**methods for loading proprietary data and adding new data**](/proudnet.eng/proudnet/db_system/db_cache_ver2/using.md#undefined), you can load Gamer and <mark style="color:orange;">CharacterInfo</mark> based on the character the user selects.<br>

Below is the approximate code.

```cpp
Proud::Guid outSessionGuid;
Proud::CDbCacheClient2* c = ...;
c->RequestExclusiveLoadData(L"Gamer",L"GamerID",gamername,outSessionGuid);
//This request receives the loadedGamerData.
 
...//Find the character the user picked in loadedGamerData.
 
c->RequestExclusiveLoadData(L"CharacterInfo",L"HeroIndex",findCharacter->heroIndex,outSessionGuid); 
//Load an info tree for the character the user selected.
```

## Migrating from DB cache ver.1

<table><thead><tr><th width="300">Item</th><th width="66" align="center">ver 1</th><th width="69" align="center">ver 2</th><th>Handling method</th></tr></thead><tbody><tr><td>Issuing credential</td><td align="center">Yes</td><td align="center">No</td><td>Must implement credential issuance yourself</td></tr><tr><td>Gamer authentication callback by DB cache</td><td align="center">Yes</td><td align="center">No</td><td>Requires a direct call instead of a gamer authentication callback</td></tr></tbody></table>

> In **DB cache ver 1**,
>
> * It covers the Gamer, Hero, and WorldObject tables, and requires you to specify the <mark style="color:orange;">OwnerUUID</mark>, <mark style="color:orange;">RootUUID</mark>, and <mark style="color:orange;">ParentUUID</mark> to move them.
> * It deals with CLoadedHeroData, CLoadedItemData, and CLoadedGamerData, which should be dealing with <mark style="color:orange;">CLoadedData</mark> instead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.proudnet.com/proudnet.eng/proudnet/db_system/db_cache_ver2/using/usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
