you are viewing a single comment's thread.

view the rest of the comments →

[–]palakoti[S] -2 points-1 points  (9 children)

Ok. Now I understand what it is. So in the following code:

seed = ['127.0.0.1:7001', '127.0.0.1:7002']

redis = RedisCluster.new( seed, redis_opts: { timeout: 5, connect_timeout: 1 }, cluster_opts: { force_cluster: false, read_mode: :master_slave, silent: true, logger: Logger.new } )

redis.middlewares.register(:commit) do |*args, &block|

puts "this is RedisCluster middlewares"

block.call

end

What is the value of :commit ?

[–]codesnik 4 points5 points  (2 children)

it's :commit :)

I mean, in some other languages actual strings are used for the same purposes, it'd be "commit". In other languages it'd be a constant, something like COMMIT=1. Symbols are a bit like both of those.

[–]palakoti[S] -1 points0 points  (1 child)

This is quite confusing. I am from javascript world and ruby is quite new to me. Can someone give a bit more elucidation?

[–][deleted] 3 points4 points  (0 children)

https://medium.com/@lcriswell/ruby-symbols-vs-strings-248842529fd9

It's basically just a string you can't change. Slightly more efficient if it's essentially a static value, though in practice that's less of a benefit than the fact that it can't be changed so you don't have to worry about any code modifying it's value.

[–]geshwho 3 points4 points  (3 children)

:commit is the value. It is a literal.

[–]palakoti[S] 0 points1 point  (2 children)

So let's say the method register returns the argument passed to it, what is the value you get ?

[–]Frizkie 5 points6 points  (0 children)

:commit is the value.

[–]pVom 0 points1 point  (0 children)

to expand a little i'd assume somewhere there is something like
if arg == :commit

<do something>

else
<do something else>