aplbrain / grand

Your favorite Python graph libraries, scalable and interoperable. Graph databases in memory, and familiar graph APIs for cloud databases.
Apache License 2.0
80 stars 6 forks source link

Add cached backend #28

Closed j6k4m8 closed 2 years ago

j6k4m8 commented 2 years ago

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 commented 2 years ago

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%) :arrow_up:
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.