Arun Agrawal’s Blog

Ruby on Rails Developer

Query Cache in Rails

By default Rails do Query cache. Whenever it execute find it enables the query cache. You can enable manually by wrapping up in cache block.
Post.cache do
  puts Post.first
  puts Post.first
  puts Post.first
end
Your development.log looks like:
Post Load (1.0ms) SELECT * FROM posts LIMIT 1
CACHE (0.0ms) SELECT * FROM posts LIMIT 1
CACHE (0.0ms) SELECT * FROM posts LIMIT 1

Refactoring Environment

Just writing about refactoring environment which can be best when you are doing refactoring in your code base. Refactoring can be done at any time of your code. When you are refactoring code you can see follow things is a benefit for you.
  1. Have some good tests for which code you are going to refactor.
  2. Let’s pair when you start refactoring. Having a pair while doing refactoring is a great idea.
  3. Code must be under version control. GIT/SVN
 

BasicObject Introduced in Ruby 1.9

RUBY_VERSION < 1.9
class Parent
end
class Child < Parent
end

puts Child.superclass   #=> Parent
puts Parent.superclass  #=> Object
puts Parent.superclass.superclass  #=> nil
RUBY_VERSION = 1.9
class Parent
end
class Child < Parent
end 

puts Child.superclass   #=> Parent
puts Parent.superclass  #=> Object
puts Parent.superclass.superclass  #=> BasicObject
puts Parent.superclass.superclass.superclass  #=> nil
So now given any class in Ruby, super class will be BasicObject for newer versions.

We Follow Deploy Early and Often

Deploy Early and Often —Steve Berczuk This process helps us to debug the deployment and installation process. In Scrum we follow needs review at the end of sprint. After that if we got potential shippable product then we deploy that so customer can use/review that feature more.

Why NoSQL?

Why NoSQL? NoSQL term is supposed to stand for “Not Only SQL.” . This term is used to designated DBMS that differ from classic RDBMS in some way. These DBMS may not require fixed table schemas, and usually avoid join operations and typically scale horizontally. Architecture NOSQL databases tend to have two key attributes across the board. One is that they’re non-relational, so they’re not doing joins on the server. And second, they have light transactional semantics. So complex, long-running, serialized transactions are not part of any of these NoSQL products. Those two differences, put together, allow you to take a very different approach to how databases are created, which means you can make horizontally scalable databases — the kind that run across large clusters of machines. RDBMS have shown poor performance on certain data-intensive applications, including indexing a large number of documents, serving pages on high-traffic websites, and delivering streaming media.  Typical RDBMS implementations are tuned either for small but frequent read/write transactions or for large batch transactions with rare write accesses. NoSQL on the other hand, services heavy read/write workloads NoSQL architectures often provide weak consistency guarantees, such as eventual consistency, or transactions restricted to single data items. Some systems, however, provide full ACID guarantees, in some instances by adding a supplementary middleware layer (e.g., CloudTPS). Core NoSQL Systems Wide Column Store/Column Families 1.Cassandra 2.Cloudera 3.Amazon SimpleDB Document Store 1. CouchDB 2. MongoDB 3. OrientDB Key Value/ Tuple Store 1.Redis 2.MemcacheDB 3.Tokyo Cabibnet