taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.04k stars 60 forks source link

freeze with carmine with lz4-compressor #148

Closed ilevd closed 2 years ago

ilevd commented 2 years ago

Try to write to Redis with lz4-compressor, found this way:

(defn write-cache [key val]
  (car/wcar redis (car/set key (WrappedForFreezing. val {:compressor taoensso.nippy/lz4-compressor}))))

it would be better to set compressor with *freeze-opts*:

(defn write-cache [key val]
  (binding [taoensso.nippy.tools/*freeze-opts* {:compressor taoensso.nippy/lz4-compressor}]
    (car/wcar redis (car/set key val))))

but it doesn't work, cause there is no merge with *freeze-opts* if the value isn't WrappedForFreezing in https://github.com/ptaoussanis/nippy/blob/master/src/taoensso/nippy/tools.clj#L36

Shouldn't merge with *freeze-opts* be there too? Btw, is there completely another way to set compressor properly (maybe in carmime)?

ptaoussanis commented 2 years ago

@ilevd Hi Igor, thanks for the report! This is indeed a bug (unintended behaviour), will be fixed in next release later today.