Comments (7)
Hi Chen, thanks for the detailed issue!
What you want here is:
(wcar* (car/set "bin-key" (car/raw (byte-array 50)))
;; bit ops go here
(car/parse-raw (car/get "bin-key")))
There's two problems you're running into with your current approach:
(car/set "bin-key" (byte-array 50))
[i.e. w/o thecar/raw
] is actually going through the Carmine serializer which is prepending a 2-byte identifier to the binary data. This is used so that later calls toget
can identify the type automatically, but it's not what you want here since you're going to be doing binary ops via Redis.- You're getting the content back as a string because the Redis-side binary ops have munged the 2-byte bin prefix, so the type is no longer identifiable and defaults to string.
The solution above instructs Carmine to send and receive in raw binary mode.
Hope that helps, cheers! :-)
from carmine.
Thanks, @ptaoussanis.
It doesn't seem to work with lua.
(wcar* (car/parse-raw (car/lua "return redis.call('get', _:key)" {:key "..."} [])))
return value is java.lang.String
Any idea?
from carmine.
It doesn't seem to work with lua
Ahh, yes - that's an interesting edge case. Going to need a little time to think about the best way of fixing this, there's a couple possibilities with different tradeoffs.
If you need a temporary workaround in the meantime:
(defn lua-workaround
[script keys args]
(let [[key-vars arg-vars var-vals] (#'car/script-prep-vars keys args)]
(apply car/eval (#'car/script-subst-vars script key-vars arg-vars)
(count keys) var-vals)))
This is exactly the same as the normal lua
fn except that it calls eval
rather than eval*
(which handles the opportunistic eval).
Will get back to you when there's a proper fix in master.
Cheers :-)
from carmine.
Was just looking at the code and found that on first lua call, when evalsha returns NOSCRIPT then car/parse-raw is working. On any subsequent call it fails.
Why is there:
(parse nil) ; Nb
on eval* code?
(let [[r & _] (->> (apply evalsha* script numkeys key args)
(with-replies :as-pipeline)
(parse nil) ; Nb
)]
Is that why it doesn't work when the function is cached in redis? Does that override any specified parser?
Thanks for the workaround
from carmine.
Is that why it doesn't work the function is cached? Does that override any specified parser?
Yes, good eye.
That's there to keep external parsers from interfering with the ability to interpret a "NOSCRIPT" error reply internally. In most cases the enclosing parsers will get their chance to apply on the (return r)
call below.
The parse-raw
case is a little unusual since it cannot be applied after-the-fact. Actually it's not a real "parser", it's just the identity fn with some metadata that gets picked up during reply parsing.
One soln would be to replace the (parse nil)
with something that disables general parsers but keeps the necessary metadata when present. There's a couple other ways we could solve the same problem though, want to weigh options a little.
from carmine.
Great. Looking forward.
from carmine.
Eh? Seems GitHub automatically closes issues with a pushed commit now - not sure if I like that.
Anyway, 2.4.4
is up with the simplest possible change for now. Let me know if you still run into any issues.
Cheers! :-)
from carmine.
Related Issues (20)
- Problems using carmine store HOT 5
- `parse-map` stop working when upgrade from 3.2.0 to 3.3.0 HOT 10
- broken link to nippy in README HOT 1
- Support commands in RediSearch, RedisJSON, RedisTimeSeries, RedisBloom HOT 2
- Handling locked messages after JVM crash HOT 3
- Carmine v4 first core pre-release
- Carmine v4 Tundra
- Carmine v4 Sentinel support
- Carmine v4 Cluster support
- message-queue/queue-names is broken (and untested) HOT 1
- Feedback on v3.3 migration instructions HOT 3
- Silently catches OutOfMemoryErrors without rethrowing HOT 8
- Mutiple atomic transactions as a pipeline HOT 3
- Unexpected behavior with `(parse-map ... :keywordize)` HOT 3
- Does Carmine support DragonflyDB? HOT 10
- Connection loss/failure detection on MQ HOT 12
- Pub/Sub posts to wrong handler fn HOT 5
- Carmine message-queue: allow throughput control HOT 4
- Block on handler being ready when creating new listeners? HOT 4
- Closing the listener produces at least one error message to handler, sometimes several. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carmine.