How to do a record view count

I've created a new module and I want to have a field that represents the number of time a record has been viewed - just like the KnowledgeBase module does.  How do I do that?