silverstripe/sapphire — pull request #637 by jaredkipe (2012-07-12 19:02:56+00:00)
Title: Toll-free-bridge to DataObject::get_one()

There were three main ways to retrieve DataObjects back in SS 2.4
DataObject::get('ClassName') which was customizable and basically replaced with ClassName::get().
DataObject::get_by_id('ClassName') which was simple and cached, replaced by ClassName::get()->byID().

Then comes DataObject::get_one('ClassName') which was inherently cached and somewhat replaced by ClassName::get()->first(). But first() obscures the fact that it is basically a separate limit(1) query and if it is cached it certainly isn't yet.

Though I think it might be better to rewrite first() and last() to use a cache, here is a direct alternative to DataObject::get_one('ClassName') with the easy to remember and use format ClassName::get()->one();