Closed lellisga closed 9 years ago
Please provide reproduction steps, including relevant environment variables, dependency versions, and code snippets.
@yaauie
r = Redis.new(:url => "redis://127.0.0.1:6379")
r.set("lellisga", "hi")
#=>"OK"
r = Redis.new(:url => "redis://127.0.0.1:6379")
me = r.get("lellisga")
#=> nil
# I was expecting this to return 'hi'
redis 127.0.0.1:6379> MONITOR
OK
# nothing happens
redis-cli 3.0.1 redis: stable 3.0.1 (bottled), HEAD
I can't seem to reproduce locally with redis-rb 3.0.1 (or the current 3.2.1) against redis-server 3.0.2 (which I have installed locally):
In one shell:
╭─{ yaauie@celeborn:~/src/yaauie/redis-rb (✔ v3.0.1/9e4c5a0) }
╰─● pry
[1] pry(main)> $: << File.expand_path('lib'); require 'redis' # uses the redis from my redis source working directory
=> true
[2] pry(main)> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.0.1 for redis://127.0.0.1:6379/0>
[3] pry(main)> r.set("lellisga", Time.now)
=> "OK"
[4] pry(main)> r.get("lellisga")
=> "2015-07-14 00:53:28 +0000"
[5] pry(main)> exit
[success]
In another shell:
╭─{ yaauie@celeborn:~/src/yaauie/redis-rb (✔ v3.0.1/9e4c5a0) }
╰─● pry
[1] pry(main)> $: << File.expand_path('lib'); require 'redis'
=> true
[2] pry(main)> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.0.1 for redis://127.0.0.1:6379/0>
[3] pry(main)> r.get("lellisga")
=> "2015-07-14 00:53:28 +0000"
[4] pry(main)> r.del("lellisga")
=> 1
[5] pry(main)> exit
[success]
and monitor:
╭─{ yaauie@celeborn:~/src/yaauie/redis-rb (✔ v3.0.1/9e4c5a0) }
╰─● redis-cli monitor
OK
1436835208.117667 [0 127.0.0.1:49386] "set" "lellisga" "2015-07-14 00:53:28 +0000"
1436835214.352837 [0 127.0.0.1:49386] "get" "lellisga"
1436835238.763373 [0 127.0.0.1:49391] "get" "lellisga"
1436835250.788366 [0 127.0.0.1:49391] "del" "lellisga"
^C
[error: 130]
If you get
a value that you have just set
in the same console, is a value returned?
yeah
irb(main):002:0> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.1.0 for redis://127.0.0.1:6379/0>
irb(main):003:0> r.set("lellisga", Time.now)
=> "OK"
irb(main):002:0> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.1.0 for redis://127.0.0.1:6379/0>
irb(main):003:0> r.get("lellisga")
=> nil
r.set('test', Time.now)
#=> "ok"
r.get('test')
#=> "2015-07-14 01:31:17 +0000"
Does the value you set in one console persist for that console?
Are all three running on the same host? In a rails console, you can type:
`hostname -f`
Can you paste the contents of your Gemfile.lock (or link to a gist that contains it)? This should include the versions of all your gems, like rails, redis-rb, and anything else you're using that could be conflicting)
irb(main):008:0> `hostname -f`
=> "mac.local\n"
irb(main):009:0> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.1.0 for redis://127.0.0.1:6379/0>
irb(main):010:0> r.set("test", "hey")
=> "OK"
irb(main):011:0> r.get("test")
=> "hey"
irb(main):012:0>
irb(main):005:0> `hostname -f`
=> "mac.local\n"
irb(main):006:0> r = Redis.new(url: 'redis://127.0.0.1:6379')
=> #<Redis client v3.1.0 for redis://127.0.0.1:6379/0>
irb(main):007:0> r.get("test")
=> nil
irb(main):008:0>
source 'https://rubygems.org'
ruby RUBY_VERSION > "2.1" ? RUBY_VERSION : "2.1.4"
gem 'rails', '4.1.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-postgis-adapter'
gem 'annotate', ">=2.6.0"
gem 'airbrake'
gem 'aws-sdk', '~> 1.5.7'
gem "chartkick"
gem 'coffee-rails'
gem 'dalli'
gem "daemons"
gem 'foursquare2'
gem 'geocoder'
gem 'groupdate'
gem 'omniauth'
gem "omniauth-facebook"
gem 'omniauth-foursquare'
gem 'paperclip'
gem 'pg'
gem "whenever", :require => false
gem 'andand'
gem 'stripe'
gem 'stripe_event'
gem 'draper', github: 'drapergem/draper'
gem 'twilio-ruby', '~> 3.11'
gem 'rack-iframe'
gem 'twitter'
gem 'sidekiq-throttler'
gem 'instagram'
gem 'fullcontact', '~> 0.9.0'
gem 'acts-as-taggable-on', '~> 3.4'
gem 'redlock'
gem 'redis'
gem 'fakeredis'
gem 'redis-namespace'
gem 'sidekiq-limit_fetch'
# Gems used only for assets and not required
# in production environments by default.
gem "sass-rails", "~> 4.0.2"
gem "select2-rails"
gem "less-rails"
gem 'twitter-bootstrap-rails', '~> 2.2.8'
gem 'bootstrap-sass'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'koala', "~> 1.11.0rc"
gem 'kaminari'
gem 'sendgrid'
gem 'uglifier'
gem 'jquery-rails'
gem "jquery-minicolors-rails"
gem 'haml'
gem 'bcrypt-ruby'
gem 'sidekiq'
gem 'sidetiq'
gem 'asset_sync'
gem 'sinatra', '>= 1.3.0', :require => nil
gem 'jquery-fileupload-rails'
gem 'aweber'
gem 'full-name-splitter'
gem 'gender_detector'
gem 'piplapis-ruby'
group :development do
gem 'thin'
gem 'traceroute'
end
group :development, :test do
gem 'rspec-rails', '~> 3.1.0'
end
group :production do
gem 'newrelic_rpm'
gem 'puma'
end
group :test do
gem 'launchy'
gem 'rspec-its'
gem 'capybara', '~> 2.4.0'
gem "timecop", '~> 0.7.1'
gem "faker"
gem "factory_girl_rails", '~> 4.5.0'
gem "shoulda-matchers", '~> 2.7.0'
gem "database_cleaner", '~> 1.3.0'
gem "vcr", '~> 2.9.0'
gem "webmock", '~> 1.20.0'
gem "rspec-sidekiq", '~> 2.0.0'
gem 'pry', '~> 0.10.0'
gem 'selenium-webdriver'
end
It looks like you're using the fakeredis
gem, which overrides code from this redis driver to create a fake redis in process memory (which explains why the value is available in process and why your redis server never gets hit); remove it from your gemfile, or ensure it is not required.
worked! thanks a lot @yaauie
When I set a value in a rails console, it doesn't store it in the redis-cli, I looked for it and cannot find it, I try to run the monitor command but it doesn't seems to store anything.