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

[entity][entity-cache-adapter-redis] move transformer responsibility … #152

Closed
wants to merge 2 commits into from

Conversation

quinlanj
Copy link
Member

@quinlanj quinlanj commented Feb 4, 2022

…to cache adapter

Why

Move the cache object <=> entity object transformation to be the Cache Adapter's responsibility. Followup to https://github.com/expo/universe/pull/9021#discussion_r794951790

Test Plan

  • new tests pass

@codecov
Copy link

codecov bot commented Feb 4, 2022

Codecov Report

Merging #152 (a38e77e) into master (a2c6dd7) will decrease coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
- Coverage   95.94%   95.74%   -0.21%     
==========================================
  Files          74       74              
  Lines        1874     1879       +5     
  Branches      204      205       +1     
==========================================
+ Hits         1798     1799       +1     
- Misses         75       79       +4     
  Partials        1        1              
Flag Coverage Δ
integration 95.74% <100.00%> (-0.21%) ⬇️
unittest 95.74% <100.00%> (-0.21%) ⬇️

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

Impacted Files Coverage Δ
packages/entity/src/EntityCacheAdapter.ts 100.00% <ø> (ø)
...ntity-cache-adapter-redis/src/RedisCacheAdapter.ts 100.00% <100.00%> (ø)
...ages/entity/src/internal/ReadThroughEntityCache.ts 95.23% <100.00%> (-0.22%) ⬇️
...kages/entity/src/utils/testing/StubCacheAdapter.ts 91.30% <0.00%> (-8.70%) ⬇️

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 a2c6dd7...a38e77e. Read the comment docs.

Copy link
Member

@wschurman wschurman left a comment

Choose a reason for hiding this comment

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

I think we can move the transformation step down one more level to the GenericRedisCacher. This will require making the GenericRedisCacher generic (no pun intended), GenericRedisCacher<TFields>. I took a stab at this to make sure it was possible: b7dbc8a (didn't add tests yet though). It seems like the combination of putting it in the GenericRedisCacher plus changing the CacheLoadResult to be generic works.

The only downside I can think of is the generic redis cacher becomes less "generic" in the sense that it can now only cache entities, but I think that's fine. The upside is that we now don't need to reference the redis transformer in the secondary loader (since it makes use of the generic cacher).

Let me know what you think.

@quinlanj
Copy link
Member Author

quinlanj commented Feb 4, 2022

closing in favour of #153

@quinlanj quinlanj closed this Feb 4, 2022
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.

2 participants