Skip to content

Add result caching to BFS path search API#5

Merged
michellechang02 merged 3 commits intomainfrom
copilot/improve-api-latency-caching
Mar 3, 2026
Merged

Add result caching to BFS path search API#5
michellechang02 merged 3 commits intomainfrom
copilot/improve-api-latency-caching

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

Implements response caching for Wikipedia path finder API endpoints to eliminate redundant BFS traversals and HTTP calls for repeated queries.

Changes

  • Dependencies: Added spring-boot-starter-cache and Caffeine 3.1.8
  • Cache configuration: 1000 entry max, 1 hour TTL
  • Cached methods: BFS.getPath() and BFS.getPathWithStats() using cache key {startURL}->{endURL}
@Cacheable(value = "pathCache", key = "#start.URL + '->' + #end.URL")
public List<String> getPath(PageNode start, PageNode end) {
  return getPath(start, end, DEFAULT_FACTORY);
}

Impact

Repeated searches for identical paths return instantly from cache instead of performing full BFS traversal. Cache eviction after 1 hour ensures reasonable data freshness.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • en.wikipedia.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/wikipediafinder/wikipediafinder/backend/build/tmp/test/work -Dorg.gradle.native=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath13875122821455852847txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 1&#39; (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/wikipediafinder/wikipediafinder/backend/build/tmp/test/work -Dorg.gradle.native=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath4019284638341231623txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 1&#39; (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/wikipediafinder/wikipediafinder/backend/build/tmp/test/work -Dorg.gradle.native=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath18061129633155251251txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 1&#39; (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve api latency and add caching</issue_title>
<issue_description></issue_description>

<agent_instructions>For the API routes, improve api latency by adding caching, make it take less time to return the JSON responses</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 3, 2026 03:47
Co-authored-by: michellechang02 <95554630+michellechang02@users.noreply.github.com>
Co-authored-by: michellechang02 <95554630+michellechang02@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve API latency by adding caching Add result caching to BFS path search API Mar 3, 2026
@michellechang02 michellechang02 marked this pull request as ready for review March 3, 2026 05:34
@michellechang02
Copy link
Copy Markdown
Owner

@copilot Make sure all tests pass, checkstyle passes, deployment will not break with vercel

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot Make sure all tests pass, checkstyle passes, deployment will not break with vercel

Verified all requirements:

All tests pass: 25/25 tests passing (including 4 new caching tests)
Checkstyle passes: Spotless formatting check successful
Vercel deployment safe: No breaking changes to API contract, JAR builds and starts correctly with new dependencies

The caching implementation is backward-compatible - the /api/getResults endpoint maintains the same signature and response format. Frontend calls will work exactly as before, but with improved performance for repeated queries.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • en.wikipedia.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/wikipediafinder/wikipediafinder/backend/build/tmp/test/work -Dorg.gradle.native=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath17072982268712230221txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 1&#39; (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/wikipediafinder/wikipediafinder/backend/build/tmp/test/work -Dorg.gradle.native=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath17570373806822056657txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 1&#39; (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@michellechang02 michellechang02 merged commit 0665782 into main Mar 3, 2026
1 check passed
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.

Improve api latency and add caching

2 participants