Reputation: 29421
Is there any functionality in StackExchange.Redis that allows you to execute raw commands directly? Like I'd provide a string with the command, e.g. (hypothetical code below):
conn.Send("ZADD mysortedset 1 john");
I know there are methods available for just about every command including ZADD
, but that's not the point.
Upvotes: 10
Views: 5875
Reputation: 1062865
The introduction of "modules" made this a lot more relevant; this API now exists in Execute(...)
. See: http://blog.marcgravell.com/2017/04/stackexchangeredis-and-redis-40-modules.html
Previously:
Not currently, and I'd be dubious of the benefit. In particular, doing this wouldn't allow correct routing on sharded instances (twemproxy, redis-cluster, etc), wouldn't allow renamed command-map usage, and wouldn't allow binary keys / values to be used. It would also allow very risky and concept-breaking commands to be used inappropriately, such as select
, watch
/multi
/exec
, blocking-pops brpop
/blpop
/brpoplpush
- all of which would be catastrophic to the multiplexer (well, select
isn't a biggie, as it can just be configured such that Send
leaves the db undefined - the code for that already exists thanks to some similar examples). It would also expose dangerous commands that should never need to be used from a general library: debug segfault
, client pause
, etc - again, all very bad ideas.
But sure, in theory it could be done... but I would really want to see a compelling reason to offset the many problems above.
At the moment, the most exposed way to execute ad-hoc commands is via ScriptEvaluate
- it would involve writing Lua, of course.
Upvotes: 9