Added onPersist callback and associated tests.

Added onPersist callback similar to onRetrieve except it is triggered when a value is stored.