Inspecting the database cache
You can look inside the current contents of the PostgreSQL shared_buffers database cache using the pg_buffercache module. This is one of the optional contrib modules available that ships with PostgreSQL; see the Chapter 1, PostgreSQL Versions for more information about making sure these are installed. An introduction to pg_buffercache is available as part of the PostgreSQL documentation at http://www.postgresql.org/docs/current/static/pgbuffercache.html
The information on how the database stores information in this chapter assumes you have this module installed, so that you can look at how blocks in shared memory change as you perform various activities. This is the best way to understand how the relevant database internals work. On a production server, using pg_buffercache may not be as vital, but it's extremely valuable for learning how the database works with its shared memory well enough to tune memory use.