Posts for: #Performances

Boost Rails Sessions

There are many dark corners and hidden features in a big framework like **Rails**.

Digging inside the code of **ActiveRecord** I discovered an interesting class: **SqlBypass**. When you set your session store on ActiveRecord it will use a **Base** subclass for deal with database store. This configuration adds an useless overhead for your application, because each session read/write will go through the complex callbacks system of ActiveRecord.

For these reason is highly advisable to use **SqlBypass**. As the name suggest it bypasses all the callbacks and simply performs read/write operations.

[]

Cached Models

cached_models provides to your models a transparent approach to use Rails internal cache mechanism.

Usually, when you decide to use cache for your ActiveRecord results, you have to manually implement complex expiring policies. cached_models simplifies your code:
class Author true end

class Post true end

That’s all!!.

A more complex example..
class Project true

has_many :tickets, :cached => true has_many :recent_tickets, :limit => 5, :order => ‘id DESC’, :cached => true end

[]