Skip to content

Conversation

@cedricherzog-passbolt
Copy link

Caching & Resource Wrapper Implementation

Implements #64 and #65

What's New

Caching (Issue #64)

Three levels of caching added to api.Client:

Cache Purpose Clears On
resourceTypesCache Avoid repeated /resource-types.json calls Login/Logout
metadataKeysCache Avoid repeated /metadata/keys.json calls Login/Logout
decryptedMetadataKeysCache Cache decrypted metadata private keys Login/Logout
sessionKeyCache Reuse session keys for faster metadata decryption Login/Logout

New Methods:

client.GetResourceTypesCached(ctx)
client.GetResourceTypeCached(ctx, typeID)
client.GetMetadataKeysCached(ctx)
client.GetDecryptedMetadataKeyCached(ctx, keyID)
client.ClearCache()

Resource Wrapper (Issue #65)

New helper.Resource struct provides unified access to v4/v5 resources with lazy loading:

// Fetch and wrap a resource
res, _ := helper.FetchResource(ctx, client, resourceID)

// Unified accessors (work for all resource types)
name, _ := res.Name(ctx)
password, _ := res.Password(ctx)    // lazy-loads secret
description, _ := res.Description(ctx)
totp, _ := res.TOTP(ctx)            // nil if not a TOTP resource

Performance Impact

  • Resource types: 1 API call per session instead of per-operation
  • Metadata keys: 1 API call + 1 decryption per session instead of per-resource
  • Session keys: ~10x faster metadata decryption on cache hit (symmetric vs asymmetric crypto)

@CLAassistant
Copy link

CLAassistant commented Dec 2, 2025

CLA assistant check
All committers have signed the CLA.

@cedricherzog-passbolt cedricherzog-passbolt marked this pull request as draft December 2, 2025 09:44
@cedricherzog-passbolt cedricherzog-passbolt added the enhancement New feature or request label Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants