Before starting with setup process lets first briefly go through what Sidekiq is? and how it works? Sidekiq provides very handy and efficient way to perform most of our work asynchronously in a job. Provided Redis cache connection to it, it serializes all job parameters in Redis and deserializes it while picking it up for execution based on priority of job as it uses queue data structure to store each job in particular queue specified in job and each queue has its priority defined as high,...

Read complete blog post

Recently we developed one feature where we wanted to present a new tab view for an existing smaller form interface whereby users can use the full screen of the new window to move around and use the feature with ease. While we were developing the feature, we came across few challenges and thereby few learnings which we thought would be good to share -

1. Caching existing values.

We have around 8-9 forms from where we can use this feature but each of them have different implementation based on...

Read complete blog post

As I am working in an app which needs keys to be stored in Redis and index data in Solr, due to redis eviction policy, sometimes keys gets evicted, but index in solar remains same, which result in confusing local behavior for me.

To clear local redis copy, I do it from redis-cli:

$ redis-cli FLUSHDB
OK exit

To remove Solr indexes, I use curl:

$ curl http://localhost:8982/solr/update?commit=true -d ':'

Read complete blog post

Rails provides three types of caching techniques:
* page caching
* action caching
* fragment caching

The railsguideson_caching is the best place to know how it works.

This article is to demonstrate fragment caching the Rails Way with various data-stores and clearing those cached fragments on ActiveRecord callbacks on CRUD operations.

Rails ActiveSupport::Cache::Store is responsible to do all the read and write operations.

1. The setup

By default caching is disabled in rails. You will find the...

Read complete blog post

What is Redis?

Redis is an open-source, networked, in-memory, key-value data store.

Why should we use Redis?

By default, Rails uses the database to cache internal application data which can be expensive to generate (menu trees, views, filter results, etc), and to keep cached page contents. Since the database also handles many queries for normal page requests, it can create a bottleneck and increase load-times. Redis provides an alternative caching backend for Rails, taking that work off the...

Read complete blog post

(Please note that the below mentioned steps and troubleshooting is not for Heroku. These are specifically for dedicated servers, VPS etc.)

Following are the steps to debug, troubleshoot and fix commonly faced Sidekiq and Redis related issues in RoR app.

1. Firstly, make sure Sidekiq URL is working.


In case if the app has restricted access to Sidekiq web url then we need to login as admin user to view sidekiq web administrator page.

2. If this url shows...

Read complete blog post

This topic is about using Redis and LUA script in Rails.

Before proceeding, you may like to read Introduction to LUA script with Redis

Redis doesn't have any command to calculate total number of keys

We'll use zrangebyscore to find number of members between index range.

Instal redis-rb

Start rails console

Prepare a dataset based on timestamp

  t10 = 10.minutes.ago
= 1386935151
 t20 = 20.minutes.ago
= 1386934568
 t30 = 30.minutes.ago
= 1386933971

Read complete blog post

What is Redis ?

We all might be familiar with Redis .
For those who are not - It's a "NoSQL" key-value data store. More precisely, it is a data structure server.
To read more - Redis-Wiki

Do try redis it has a nice interactive tutorial.

To install and setup redis on your machine see how-to-install-and-use-redis

What is LUA ?

LUA is an embeddable scripting language. About LUA -
Redis = 2.6 supports embedded scripting language.

Lets give a try to it.

To run a...

Read complete blog post

Redis installation at local is one of the easiest things to do. However, There are some gotchas involved when we are trying to use redis.

1) Running redis-server without config(Default Config File will be picked).

When we run redis-server without config, then it creates a dump.rb(A physical file to store all data related to redis) at the folder from which we are starting the redis. We normally, don't realize the impact of this issue as we start the redis server at the same project folder...

Read complete blog post