I have a memcached container and a Rails App.
If a I have loop doing this:
100.times do
puts Rails.cache.read('yes')
sleep(0.5)
end
And I open the Rails console to write into the cache
Rails.cache.write('yes', 'value')
I will still have a nil value in my put.
But if a write/read from the console or directly from the app, it works well.
What I am doing wrong ? Or what did I miss ?
Thanks in advance
Here's the configuration of memcached in my production.rb file
config.cache_store = :mem_cache_store, ENV['MEMCACHED_HOST']
More info:
If I write into the cache and launch the app, it will catch the value.
Both Rails app and Memcached are Docker containers.
Rails version: 5.1.5
Ruby version: 2.5.0
Gem Dalli version: 2.7.8
Memcached version: 1.5.10
Docker version: 18.03.1
Related
After upgrading the redis version in order to upgrade to sidekiq version 7. Whenever I try to write to the cache it returns false. But sidekiq works correctly.
Sidekiq 7.0.0
redis gem 5.0.5
redis 7.0.5
3.1.1 :003 > Rails.cache
=> #<ActiveSupport::Cache::RedisCacheStore options={:namespace=>nil, :compress=>true, :compress_threshold=>1024, :expires_in=>nil, :race_condition_ttl=>nil} redis=#<Redis client v5.0.5 for redis://127.0.0.1:6379/0>>
3.1.1 :005 > Rails.cache.write 'test', 'test'
=> false
EDIT:
Solved.The problem was in the new redis.conf file that was generated when upgrading.
I have upgraded my rails app from rails 2x to 3.2.3. But facing a weird issue.
Any changes I do in controller and model are not reflecting until I restart my rails server.
Caching is disabled in my development.rb as
config.cache_classes = false
config.action_controller.perform_caching = false
But it doesn't work. I even tried updating my rails version to 3.2.5
My application configuration is
Ruby version : ruby 1.9.3p194 with RVM
Rails version : 3.2.3
Application server: webrick
Webserver: Apache
Thanks in advance
I've been trying to get my Rails application to work TorqueBox and one of its requirements is to use JRuby as the Ruby language variant. I've installed JRuby 1.6.6 and the gemfile seems to bundle itself properly, but when the rails server is booted up and accessed within a browser (at localhost:3000 or 0.0.0.0:3000) then the webpage hangs...
I'm not sure if this is a problem with Rails 3.2 and the rails server does start fine (doesn't show any errors within the console) and the Rails 3.2 instance does work with Ruby 1.9.2. So I think it may be something with my gem file list or perhaps something within an initializer.
Any ideas if this is a common problem?
--- EDIT ---
I'm trying to access 0.0.0.0:3000 from WebBrick.
As far as I know torquebox 2.0 beta 3 is currently tested with jruby 1.6.5.1. Maybe try switching to that jruby version. Also make sure you're running ruby in 1.9 mode. To do that, create a torquebox.yml file in your rails config folder and put the below in it:
ruby:
version: 1.9
I am working on a web application running on Rails 2.1 version.
I would like to know if there is any single command in rails or ruby that could fetch me in the console, all the details about my application like the version of my back end DB, Rails, Ruby and all relevant information pertaining to my web app.
This would help me to get all necessary details of my application without having to explicitly
look into each of the details one by one.
I think you can try the ruby script/about command for your rails app. This must work for the Rails 2.1 version.
Running this in the console would give you major environment details about your web application. Something similar to this :
Go to the app directory and run the command
$ ruby script/about
About your application's environment
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.8.11
Rails version 2.1.2
Active Record version 2.1.2
Action Pack version 2.1.2
Active Resource version 2.1.2
Action Mailer version 2.1.2
Active Support version 2.1.2
Edge Rails revision e0a2f6c625d99d68df432a3c3418f4217bd56cbf
Application root /home/path/app_folder #path of your app directory
Environment production
Database adapter mysql
Database schema version 20101110130106
When running a job with delayed_job, I get errors when trying to access the Dalli Cache.
The Dalli cache is initialized in environment.rb with the following...
CACHE = Dalli::Client.new(['localhost:11211'], {:namespace=>my_namespace_method})
When the code executes CACHE.get 'my_key' in my rails app, everything runs fine.
When it runs in a delayed_job worker, it errors with No Server Available
Other info that might help:
I have confirmed that the memcached server is running and is accessible via telnet on localhost:11211
We're running Ruby 1.9.2 under rvm