Closed javierarrieta closed 9 years ago
Hi, Could you explain why ? because Sort is read-only, so unless there is a big replication lag for the slave, it should be fine
Hi, it is not read only, it writes the sorted elements in the list. It is surprising that it is not clear in the reference doc, but you can easily reproduce issuing that command against a slave
There is the rediscala sort store command
I have spitted the command, Sort and SortStore https://github.com/etaty/rediscala/blob/ab29ee24b024b8dced58f618d6a32bb91ba91bf2/src/main/scala/redis/api/Keys.scala#L144-L166
Yeah, I don't understand too much the difference since both are issuing a redis SORT command that will rewrite the list to the key. We are using the sort command, not the sortStore
sortstore will read, then write (store) sort will only read
you can't store
with the rediscala sort
you have to use sortStore
Sorry, but redis sort command writes to the key, as said it is quite easy to reproduce manually. I have been looking in the rediscala tests to see if I could easily make it apparent in those
I have splitted the redis sort
command in rediscala
sort
(only read) sortStore
(read then write)And again I don't know how that could be beneficial as SORT command writes to the key
127.0.0.1:16379> lrange mylist 0 -1
1) "3"
2) "4"
3) "2"
4) "1"
127.0.0.1:16379> sort mylist
(error) READONLY You can't write against a read only slave.
I can solve hopefully my issue using sortStore, but anyone trying to use sort would have this issue (and could be bad if they introduce master-slave after deploying to prod, so code failing in production)
Oh ok never saw that error before, I will need to check it
Cool, thanks @etaty
SORT redis command is master only, so we need to configure the case class for that command accordingly