Skip to content

Reuse successful LDAP base searches - #79

Merged
hosom merged 3 commits into
mainfrom
hosom/cache-known-ldap-bases
Sep 14, 2026
Merged

hosom merged 3 commits into
mainfrom
hosom/cache-known-ldap-bases

Conversation

@hosom

@hosom hosom commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

In benchmarking, I discovered that we have a number of situations where we check to see if a DN exists during the same runtime and in many cases do so repeatedly.

This change keeps an in memory cache of the DNs already checked so that we don't need to do 2-3 lookups of the same DN with exists? against live LDAP.

In the benchmarks I ran, this eliminated as much as 50% of the LDAP queries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5b8ed060-ed02-4402-b5e1-af407bcb2f61
Copilot AI balanced review requested due to automatic review settings September 12, 2026 04:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Successful deletions must invalidate cached existence to prevent stale results.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced (auto)
Findings: 1 Medium severity

Note

Copilot is running an experiment and ran this review at Balanced.

Open findings (1)
What changed in this PR

Caches successfully searched LDAP bases to avoid redundant existence queries during calculation.

Changes:

  • Adds synchronized tracking of known-existing DNs.
  • Reuses successful searches in exists?.
  • Adds success/failure cache tests and corrects connection comments.
File Description
lib/​entitlements/​service/​ldap.rb Implements synchronized LDAP base caching.
spec/​unit/​entitlements/​service/​ldap_spec.rb Tests successful and failed search caching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/entitlements/service/ldap.rb
Clear both known-existence and read caches after a successful LDAP delete so later checks re-read the directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3f79283a-9bd3-46dd-8e33-676d145619c5
Prepare the LDAP cache optimization for publication on merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3f79283a-9bd3-46dd-8e33-676d145619c5
@hosom
hosom merged commit f934a82 into main Sep 14, 2026
19 checks passed
@hosom
hosom deleted the hosom/cache-known-ldap-bases branch September 14, 2026 20:42
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.

3 participants