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
Marcos Alvares (author)
Sun Sep 07 07:31:54 -0700 2008
commit  69b439c9344ea0352e2ac56fbdd312cb097f43c0
tree    066ce3c5f61167adf2d2c8704de8a7eb3d98ec85
parent  31c4842845c4268450fa5cf82a7ea3ef739e4099
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
README
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