unstorage icon indicating copy to clipboard operation
unstorage copied to clipboard

fix: add colon to redis deprefix

Open denisugo opened this issue 11 months ago • 6 comments

Resolves #585

denisugo avatar Jan 29 '25 17:01 denisugo

out of interest, how did you bump into this? do you use the driver directly? i.e. rather than Storage

i think your fix makes sense, but getKeys in the result of createStorage(...) already strips : from the start of these keys

so would be good to know what situation you were in where you got the underlying key, rather than the one Storage has already normalised

43081j avatar Feb 19 '25 15:02 43081j

I copied the code for the redis driver and used it as a custom driver, however the implementation of d() and p() remained unchanged(it was simply copy-pasted) and it didn't support the colon removal.

denisugo avatar Feb 25 '25 08:02 denisugo

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 60.28%. Comparing base (70310f9) to head (87ed4c1). Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #586      +/-   ##
==========================================
+ Coverage   59.99%   60.28%   +0.28%     
==========================================
  Files          42       42              
  Lines        3657     3681      +24     
  Branches      590      597       +7     
==========================================
+ Hits         2194     2219      +25     
+ Misses       1460     1459       -1     
  Partials        3        3              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Feb 25 '25 08:02 codecov[bot]

so you used it directly rather than via Storage/createStorage?

good to know if so!

basically if you make it via createStorage, it will normalise those keys for you and strip the : already.

though i still think its a good idea for the driver itself to do that 👍

43081j avatar Feb 25 '25 09:02 43081j

Well, I did use createStorage, but I also used a custom redis driver, whose entire implementation was copied from the standard redis driver used by unstorage

denisugo avatar Mar 25 '25 14:03 denisugo

So, the code looks like

createStorage({driver: myRedisDriver(...)})

denisugo avatar Mar 25 '25 14:03 denisugo