public
Description: This rails plugin works as a LRU(Least Recently Used) cache algorithm , it discarts the least rencently used item and store the new one.
Homepage:
Clone URL: git://github.com/mabj/acts_as_lru.git
name age message
file LICENSE Loading commit data...
file README
file Rakefile
file init.rb
file install.rb
directory lib/
directory tasks/
directory test/
file uninstall.rb
ActsAsLru
=========

This rails plugin transform a ActiveRecord object in a cache pool wich uses the Least Recently Used (LRU) Cache 
algorithm. 
It discards the least recently used items first. The usage to this plugins is analysis on the recently portion of a time 

series in real time applications, without necessity of store a lot of entries.

Example
=======
belongs_to :asset

##################### [Example]

class FakeClass < ActiveRecord::Base
  acts_as_lru :cache_size => 3, :index_column => [:index_column], :order_column => :updated_at
end

FakeClass.create(:index_column => 1); FakeClass.count;  # => 1
FakeClass.create(:index_column => 1); FakeClass.count;  # => 2
FakeClass.create(:index_column => 1); FakeClass.count;  # => 3    # First LRU serie with :index_column => 1
FakeClass.create(:index_column => 1); FakeClass.count;  # => 3
FakeClass.create(:index_column => 1); FakeClass.count;  # => 3
# ...
FakeClass.create(:index_column => 2); FakeClass.count;  # => 4
FakeClass.create(:index_column => 2); FakeClass.count;  # => 5      
FakeClass.create(:index_column => 2); FakeClass.count;  # => 6    # Second LRU serie with :index_column => 2
FakeClass.create(:index_column => 2); FakeClass.count;  # => 6
FakeClass.create(:index_column => 2); FakeClass.count;  # => 6    # Each serie has at most three elements
# ...

#####################

 - index_column: is not required. Each column especified must be a valid attribute in the model.
 - cache_size: is not required and the default value is twenty.
 - order_column: is not required and the default value is "updated_at".



Copyright (c) 2008 Marcos Alvares, released under the MIT license