Skip to content

Conversation

@daukadolt
Copy link
Contributor

@daukadolt daukadolt commented Oct 23, 2025

Description

This PR implements filesystem-based cache for cognee short-term memory (#1545)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please specify):

Screenshots/Videos (if applicable)

Pre-submission Checklist

  • I have tested my changes thoroughly before submitting this PR
  • This PR contains minimal changes necessary to address the issue/feature
  • My code follows the project's coding standards and style guidelines
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if applicable)
  • All new and existing tests pass
  • I have searched existing PRs to ensure this change hasn't been submitted already
  • I have linked any relevant issues in the description
  • My commits have clear and descriptive messages

DCO Affirmation

I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.

@daukadolt daukadolt requested a review from hajdul88 October 23, 2025 15:27
@pull-checklist
Copy link

Please make sure all the checkboxes are checked:

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have added end-to-end and unit tests (if applicable).
  • I have updated the documentation and README.md file (if necessary).
  • I have removed unnecessary code and debug statements.
  • PR title is clear and follows the convention.
  • I have tagged reviewers or team members for feedback.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fs-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@daukadolt
Copy link
Contributor Author

daukadolt commented Oct 23, 2025

Looks like redislite has issues with win 32

@daukadolt daukadolt marked this pull request as draft October 24, 2025 13:15
@daukadolt daukadolt changed the title Feat/fs-cache (redislite) Oct 27, 2025
@daukadolt daukadolt marked this pull request as ready for review October 27, 2025 13:49
@Vasilije1990
Copy link
Contributor

@daukadolt do you need a review of this one?

@daukadolt
Copy link
Contributor Author

daukadolt commented Oct 28, 2025

Only distributed cognee is failing due to poetry.lock

@hajdul88
Copy link
Collaborator

I tested it.

Problems I found:
-This is memory based session implementation not file based. Therefore session are not gonna persist. I think the objective was to create file based adapter.
-By setting this fs based solution the behavior of the following tests may change so please make sure they run with Redis and not with this solution
-Concurrent Subprocess Access Test
-Conversation sessions test

Also I think it would be a good idea to cover this adapter with the Conversation sessions tests so we test both Redis and fs behavior.

@daukadolt
Copy link
Contributor Author

Just validated it works with kuzu multiprocessing test.

I'll make a copy of the test for FS caching

@hajdul88
Copy link
Collaborator

I fixed the two redis tests. Tested sessions they don't work now.

@daukadolt daukadolt changed the title Feat/fs-cache (fakeredis) Oct 28, 2025
@borisarzentar borisarzentar changed the title Feat/fs-cache Oct 30, 2025
data_root_directory = storage_config["data_root_directory"]
cache_directory = os.path.join(data_root_directory, ".cognee_fs_cache", lock_key)

os.makedirs(cache_directory, exist_ok=True)
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to always be in the local filesystem?


self.lock.release()

async def add_qa(
Copy link
Member

Choose a reason for hiding this comment

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

Do we have this in redis adapter as well?



def test_can_release_lock():
cache = FSCacheAdapter(timeout=5, blocking_timeout=10, lock_key="test_release")
Copy link
Member

Choose a reason for hiding this comment

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

This one is the same as previous.

def test_releasing_non_acquired_lock():
try:
cache = FSCacheAdapter(timeout=5, blocking_timeout=10, lock_key="test_non_acquired")
cache.acquire_lock()
Copy link
Member

Choose a reason for hiding this comment

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

We acquire it, how is it non acquired?

@pytest.mark.asyncio
async def test_closing_connection():
cache = FSCacheAdapter(timeout=1, blocking_timeout=10, lock_key="test_closing")
await cache.close()
Copy link
Member

Choose a reason for hiding this comment

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

Why do we call cache.cache.close() above and cache.close() here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants