Wednesday, September 21, 2005
I’ve just released Lafcadio 0.8.0, the new production release. It contains more than 40 new features and bugfixes. And it adds lots of convenience methods to DomainObject, richer query inference operators, real-time query subset caching—all in a slimmer codebase.
Some new features are:
class User < Lafcadio::DomainObject
strings :fname, :lname, :email
end
maybe_koreans = User.get { |u| u.lname.in( 'Park', 'Lee', 'Hwang' ) }
no_fname = User.get { |u| u.fname.nil? }
As always, these queries work both against MySQL and against a much faster, in-memory mock object store for use in testing.
Everytime you run a select against the DB, Lafcadio caches the results in memory. Then, if you later run a second select that is a subset of the first, Lafcadio detects it, figures out what it’s a subset of, filters out the results in memory, and returns you the results. This all happens transparently.
What does this mean? It means a significantly faster app, because if you run these three queries:
select * from users where lname = 'Smith' select * from users where lname = 'Smith' and fname like '%john%' select * from users where lname = 'Smith' and email like '%hotmail%'
Lafcadio will only ask MySQL for the results for the first select statement, and do the rest for you without using the DB connection.
puts User.exist? u = User[15] u.update!( :fname => 'Bill' ) u.delete! all_users = User.all first_user = User.first last_user = User.last
Tagged: ruby
<< MockFS 0.1.2 (Sep 19 2005) | Face time for RubyConf 2005 (Oct 5 2005) >>