Note that I decide that the popularity
count should be protected by the cache_lock rather
than the per-object lock: this is because it (like the
struct list_head inside the object) is
logically part of the infrastructure. This way, I don't need to grab
the lock of every object in __cache_add when
seeking the least popular.

I also decided that the id member is
unchangeable, so I don't need to grab each object lock in
__cache_find() to examine the
id: the object lock is only used by a
caller who wants to read or write the name
field.

Note also that I added a comment describing what data was protected by
which locks. This is extremely important, as it describes the runtime
behavior of the code, and can be hard to gain from just reading. And
as Alan Cox says, “Lock data, not code”.