Compression doesn't seems to be consistent
See original GitHub issueI was considering updating keyv
library to the latest version and switching the custom compression wrapper to one of the new packages. Unfortunately I found couple of potential issues I would like to discuss.
- Looks like:
compress?: Record<string, unknown> | undefined;
from Keyv.Options interface are no longer used in code.
-
New
compression
parameter used in the Keyv implementation doesn’t seem to have a clear interface that could be used to define theKeyvBrotli
,KeyvGzip
or any other future implementations. -
The approach of using
opts
object created insideKeyvBrotli
andKeyvGzip
instead of methods defined by common interface seems to be a dodgy approach. It doesn’t make it easier to work on future integrations. -
Both
KeyvBrotli
andKeyvGzip
seems to be defining only two methods in Options interface that when passed to the constructor are immediately overwritten. Additionally compress and decompress methods are being defined in those two classes, which makes it even harder to understand how the code should behave. -
I’m not sure if either of those
extends EventEmitter implements Store<Value>
is really needed inKeyvBrotli
andKeyvGzip
. -
There is not TypeScript compatible way to provide compression-method-related parameters down to the compressors.
I know that’s a lot, but I think current approach is bugged and I would be happy to jump on a call to talk all of those points through.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
@kdybicz - will be working on some clean up for this in a pull request and will tag you in on it.
@kdybicz - will be closing this as the v2 architecture is now in main and will be released soon. We decided to keep the overwrite of
serialize
anddeserialize
functions in the compress function to simplify the current architecture in Keyv. With that said we will evaluate over time and might move to just needingcompress
anddecompress
.In addition we have added an interface for this to standardize and have updated more of the code to work better and validated it.