Skip to content

ActiveRecord Refactoring

technoweenie edited this page Sep 12, 2010 · 18 revisions

We intend to clean up some of the internals of active record, if you’re interested in helping out, add your ideas here.

Callback chain for record instantiation

  • To allow hooks for pluggable cache strategies
  • SQL SELECT table_name.id CONDITIONS
  • Less DB traffic ( single column only )
  • [pk1, pk2, pk3] => Cache Lookups via Memcached

Identity Map

Maybe? What else would we gain?

For one, the need to call reload all over the place would mostly disappear and the stale data bugs those calls to reload represent would go away.

There are two approaches I’m researching.

  • A simple hash, like datamapper, using a simple block approach for clearing it after a request, like the query cache.
  • A weak hash implementation where no explicit clearing is needed, the garbage collector handles it for us

See one basic implementation in the active_record_context plugin. It’s been serving me very well in Lighthouse.

Clone this wiki locally