Cache Invalidation Complexity: Rails 5.2 and Dalli Cache Store

Rails applications that use ActiveRecord objects in their cache may experience an issue where the entries cannot be invalidated if all of these conditions are true:

They are using Rails 5.2+
They have configured config.active_record.cache_versioning = true
They are using a cache that is not maintained by Rails, such as dalli_store

In this post, we discuss the background to a change in the way that cache keys work with Rails, why this change introduced an API incompatibility with third-party cache stores, and finally how you can find out if your app is at risk and how to fix it.


Making Ruby Yours

Pulling at a Loose Thread
One day I noticed an inconsistency as I was joining together lists of words. Consider this no-delimiter join:
arr = [ [‘some’, ‘lists’], [‘of’, ‘different’, ‘words’] ] # => [‘somelists’, ‘ofdifferentwords’]
It’s point-free and clean, aside from the funny ampersand.


Rails Associations

An association is a connection between two Active Record models. It makes it much easier to perform various operations on the records in your code. We will divide associations into four categories:

Polymorphic One-to-Many

If you are new to Ruby on Rails, be sure to get up your rails project ready and check how to create models in Rails.


Go vs. Ruby on Rails

Ruby Performance:
Almost all of our clients complained about slow performance in their Ruby apps; which was leading to concurrency bottlenecks. This hits performance and the time it took to complete a job was not satisfactory. In contrast, Golang was able to handle a huge load of concurrent requests without slowing down the performance of a program. This is why enterprises with web-based applications, found that Golang based programs were able to handle several users at one time without ever underperforming.
Scalability is almost always a result of concurrency. An application which can handle concurrent requests is more likely to be scalable. We realized when Rails gets to a significant enough scale, the runtime speed diminishes significantly, resulting in poor performance. Golang, on the other hand, outshines this test by scaling automatically to multiple cores. This ensures that organizations don’t have to worry about migrating costs once the business scales up.


How to Implement a Ruby Hash Like Grammar in Parslet, Part 2

Welcome back! If you missed Part 1, you can check it out here.
Transformers – Abstract Syntax Trees in Disguise
I mentioned transformers previously, but they’re such an abstract concept that it helps to look at an example. Think of them as a way to reduce leaf nodes on our tree so that they make more sense. One way to represent our current parse tree is this:


How to Implement a Ruby Hash Like Grammar in Parslet, Part 1

Before you can understand how to build a parser using parslet, you need to understand why you might want to. In my case, I have a library called rundoc, it allows anyone to write documentation that can be “run." For example, someone might write docs that had this:
:::>> $ rails -v
Then in your documentation output, you would get this result:


Opal – Ruby on JavaScript VM – What’s Still Missing

JavaScript VMs are everywhere, and environments running them such as browsers and phones look likely to remain the dominant way for users to interact with software for a very long time. This led to an explosion in the popularity of JavaScript – the native language of that environment.
But JavaScript is a dreadful language. It started a dirty hack, which just so happened to be positioned right and benefited from browsers becoming the universal user interface. It can’t even ever get properly fixed like, let’s say, Python 1, due to unique backward compatibility cost.


RSpec Rails Controller Test

Rails is a web development framework, where model, view, and controller are important aspects of your application. Controllers, just like models and viewers, need to be tested with the Ruby community’s favorite tool, RSpec.
Controllers in Rails accept HTTP requests as their input and deliver back and HTTP response as an output.


Rails Bundle Install and Gemfile

Bundler makes sure that Ruby applications always use the exact gems and versions that you need while keeping a consistent environment and gem dependencies satisfied. This is done by ensuring that the gems you need are present in the development, staging, and production stages.
Setting Up a Bundler
With these three simple steps that every beginner should know to get your application up and running with bundler: