stretchr/hoard — pull request #27 by hknauer (2013-11-16 14:37:52+00:00)
Title: Bug fix and more

Hi Tyler,

I ended up doing quiet some changes now:

- New function (h *Hoard) SetExpirationCheckInterval(d time.Duration) to set the desired time interval for the flushManager

- Added duration field to expiration, to work the same way idle does. After* functions now set the duration instead of a absolute point in time directly, thus making it independend of the creation time. This allows to reuse expiration objects created at anytime, like the defaultExpiration stored in a Hoard object.

Memory optimizations:
- Introduced new container type expirationContainer. It's the same as the former container, but does not contain the data payload. Accordingly, the expirationCache map of a Hoard object now contains these expirationContainers clones of the original container instead of copys of the original container with payload.

- Mutexes for single keys stored in keyDeadbolts now get deleted after they are no longer needed.

Performance optimization:
- The new Expiration.IsExpired function has to check and compute timestamps for duration (after), idle (afterIdle), date (onDate) and condition. To avoid these calculations during mass flushManager calls, Expiration.isExpiredAbsolute has been added, which just compares an absolute time.
For this to work, the absolute time has to be set, whenever the container object is updated in expirationCache by calling Expiration.updateAbsoluteTime

Other changes:
- Removed some unused functions
- Adjusted tests

Cheers,
Holger