entity icon indicating copy to clipboard operation
entity copied to clipboard

feat: alternative sharded redis cache

Open wschurman opened this issue 2 years ago • 1 comments

Why

This is the alternative to https://github.com/expo/entity/pull/196 mentioned in https://github.com/expo/entity/pull/196#issuecomment-1267750484.

How

Instead of doing the sharding logic in the entity cache adapter level, do it within the redis interface. This requires some bookkeeping and tricks within the multi-redis logic, but isn't horrendous.

The main thing to review is the ShardedRedis class in the test. This is what would need to be duplicated to an application that uses it (though with a real consistent hash).

Test Plan

Run test (same test as other PR to prove it works).

wschurman avatar Oct 05 '22 17:10 wschurman

Codecov Report

Merging #197 (6f53cf0) into main (dbf1e03) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #197   +/-   ##
=======================================
  Coverage   96.17%   96.17%           
=======================================
  Files          81       81           
  Lines        2065     2065           
  Branches      269      245   -24     
=======================================
  Hits         1986     1986           
- Misses         74       79    +5     
+ Partials        5        0    -5     
Flag Coverage Δ
integration 96.17% <100.00%> (ø)
unittest 96.17% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...tity-cache-adapter-redis/src/GenericRedisCacher.ts 100.00% <ø> (ø)
...ntity-cache-adapter-redis/src/RedisCacheAdapter.ts 100.00% <100.00%> (ø)
packages/entity/src/EntityLoader.ts 89.36% <0.00%> (ø)
...ty-example/src/adapters/InMemoryDatabaseAdapter.ts 45.83% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Oct 05 '22 18:10 codecov[bot]

This was a proof of concept. No longer needed for now.

wschurman avatar Mar 31 '23 18:03 wschurman