add purge interval

Periodically purge expired items.

BTW, I think it's better to write tests instead of examples.