Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Databuckets] Add Account Scoped Databuckets #4603

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

Akkadius
Copy link
Member

@Akkadius Akkadius commented Jan 21, 2025

Description

Adds support for Account Scoped Databuckets

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

In the below example, one (example3) should expire in a second, example2 should be deleted and only example1 should return a value

sub EVENT_SAY
    # set 3 variations
    if ($text=~/set_account/i) {
        $client->SetAccountBucket("example", "1");
        $client->SetAccountBucket("example2", "1");
        $client->SetAccountBucket("example3", "1", "1S");   
    }

    # one expires, we delete the second, the first should be the only one to return a value
    if ($text=~/get_account/i) {
        $client->DeleteAccountBucket("example2");
        $client->Message(15, "example1 " . $client->GetAccountBucket("example"));
        $client->Message(15, "example2 " . $client->GetAccountBucket("example2"));
        $client->Message(15, "example3 " . $client->GetAccountBucket("example3"));
    }
}

image

Similar test conducted in Lua

image

function event_say(e)
    -- Setting account buckets
    if e.message:findi("set_account") then
        e.self:SetAccountBucket("example", "1")
        e.self:SetAccountBucket("example2", "1")
        e.self:SetAccountBucket("example3", "1", "1S")   
    end

    -- Getting account buckets
    if e.message:findi("get_account") then
        e.self:DeleteAccountBucket("example2")
        e.self:Message(15, "example1 " .. e.self:GetAccountBucket("example"))
        e.self:Message(15, "example2 " .. e.self:GetAccountBucket("example2"))
        e.self:Message(15, "example3 " .. e.self:GetAccountBucket("example3"))
    end
end
mariadb> SELECT * FROM `data_buckets` WHERE `key` = 'example' LIMIT 0,1000;
+----+---------+-------+---------+------------+--------------+--------+--------+
| id | key     | value | expires | account_id | character_id | npc_id | bot_id |
+----+---------+-------+---------+------------+--------------+--------+--------+
| 24 | example | 1     |       0 |          1 |            0 |      0 |      0 |
+----+---------+-------+---------+------------+--------------+--------+--------+
1 row in set (0.00 sec)

Caching

When client loads into zone

Account scoped

  Zone | DataBucket | BulkLoadEntitiesToCache cache size before [0] l size [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [24] bucket key [example] bucket value [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache cache size after [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache Bulk Loaded ids [1] column [account_id] new cache size is [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]

Character scoped

  Zone | DataBucket | BulkLoadEntitiesToCache cache size before [1] l size [6] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [2] bucket key [test_key] bucket value [something] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [23] bucket key [progression] bucket value [{"progression":{"classic":{"nagafen_killed":"1","vox_killed":"1"},"don":{"good":{"step1":"done","step2":"done"}}}}] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [28] bucket key [progression.don.good.step1] bucket value [done] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [29] bucket key [progression.don.good.step2] bucket value [done] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [30] bucket key [progression.classic.nagafen_killed] bucket value [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache bucket id [31] bucket key [progression.classic.vox_killed] bucket value [1] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache cache size after [7] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | BulkLoadEntitiesToCache Bulk Loaded ids [1] column [character_id] new cache size is [7] -- [poknowledge] (The Plane of Knowledge) inst_id [0]

Character leaves zone

Expected to see no buckets in cache

  Zone | DataBucket | DeleteCachedBuckets LoadType [Account] id [1] cache size before [7] after [6] -- [poknowledge] (The Plane of Knowledge) inst_id [0]
  Zone | DataBucket | DeleteCachedBuckets LoadType [Client] id [1] cache size before [6] after [0] -- [poknowledge] (The Plane of Knowledge) inst_id [0]

Checklist

  • I have tested my changes
  • I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
  • I own the changes of my code and take responsibility for the potential issues that occur
  • If my changes make database schema changes, I have tested the changes on a local database (attach image). Updated version.h CURRENT_BINARY_DATABASE_VERSION to the new version. (Delete this if not applicable)

@Akkadius Akkadius force-pushed the akkadius/account-databuckets branch from 729f310 to 3450d35 Compare January 21, 2025 21:55
@Akkadius Akkadius merged commit 37ced4b into master Jan 21, 2025
2 checks passed
@Akkadius Akkadius deleted the akkadius/account-databuckets branch January 21, 2025 22:06
@Akkadius Akkadius mentioned this pull request Jan 27, 2025
joligario added a commit to ProjectEQ/peqphpeditor that referenced this pull request Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants