Skip to content

[Memory] Unbounded static database cache in FoundationDB #46

Description

@s2x

Context / Problem

FoundationDB keeps a static cache of Database objects that is never evicted except by an explicit close():

src/FoundationDB.php:16-17private static array $databases = [];
src/FoundationDB.php:98-115openWithConnectionString() caches by 'conn:' . $connectionString

An application that opens many distinct cluster files or connection strings (multi-tenant, dynamic connection strings) holds a growing number of native FDBDatabase handles for the entire process lifetime.

Affected files / locations

  • src/FoundationDB.php:16-17,59-116

Proposed approach

Document that cached databases live for the process lifetime and require close(), and bound the growth: either do not cache the connection-string variant, or apply a small bounded cache with explicit eviction. Ensure evicted databases are properly destroyed.

Acceptance Criteria

  • Documentation updated/added (cache lifetime and ownership)
  • Unit test(s) added covering cache insertion/eviction/close removal
  • Functional test(s) added: opening many distinct connection strings does not retain unbounded handles
  • Changelog entry added
  • Post-implementation comment posted on this issue describing what was changed

Severity

Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions