Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cached backend #28

Merged
merged 4 commits into from
Feb 4, 2022
Merged

Add cached backend #28

merged 4 commits into from
Feb 4, 2022

Conversation

j6k4m8
Copy link
Member

@j6k4m8 j6k4m8 commented Feb 4, 2022

Fixes #20.

Adds a backend cache:

from grand.backends import SQLBackend, InMemoryCachedBackend
from grand import Graph

G = Graph(backend=InMemoryCachedBackend(SQLBackend(...)))

G.nx.degree(42) # May be slow if the graph is very large
G.nx.degree(42) # Will be very fast, since the result is cached
G.backend.clear_cache() # Clear the cache explicitly

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2022

Codecov Report

Merging #28 (52721e7) into master (ee89e73) will increase coverage by 3.89%.
The diff coverage is 98.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #28      +/-   ##
==========================================
+ Coverage   51.59%   55.48%   +3.89%     
==========================================
  Files          15       16       +1     
  Lines        1068     1166      +98     
==========================================
+ Hits          551      647      +96     
- Misses        517      519       +2     
Impacted Files Coverage Δ
setup.py 0.00% <ø> (ø)
grand/backends/backend.py 80.89% <95.00%> (+10.89%) ⬆️
grand/backends/__init__.py 86.66% <100.00%> (ø)
grand/backends/test_cached_backend.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee89e73...52721e7. Read the comment docs.

@j6k4m8 j6k4m8 merged commit 058d8df into master Feb 4, 2022
@j6k4m8 j6k4m8 deleted the add-cached-backend branch February 4, 2022 23:13
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.

Optionally support TTL cache on Backend function calls
2 participants