NAME MooseX::AutoDestruct - Clear your attributes after a certain time VERSION version 0.009 SYNOPSIS package Foo; use Moose; use namespace::autoclean; use MooseX::AutoDestruct; has foo => ( traits => [ AutoDestruct ], is => 'ro', isa => 'Str', lazy_build => 1, ttl => 600, # time, in seconds ); sub _build_foo { --some expensive operation-- } DESCRIPTION MooseX::AutoDestruct is an attribute metaclass trait that causes your attribute value to be cleared after a certain time from when the value has been set. This trait will work regardless of how the value is populated or if a clearer method has been installed; or if the value is accessed via the installed accessors or by accessing the attribute metaclass itself. TRAITS APPLIED No traits are automatically applied to any metaclasses; however, on use'ing this package an 'AutoDestruct' attribute trait becomes available. Moose will properly deduce what trait you're talking about if you pass AutoDestruct as a string -- e.g.: has foo => (traits => [ 'AutoDestruct' ], ...) However, this is depreciated in favor of the exported trait alias: has foo => (traits => [ AutoDestruct ], ...) USAGE Apply the AutoDestruct trait to your attribute metaclass (e.g. "traits => [AutoDestruct]") and supply a ttl value. Typical usage of this could be for an attribute to store a value that is expensive to calculate, and can be counted on to be valid for a certain amount of time (e.g. caching). Builders are your friends :) SEE ALSO Moose. BUGS Please report any bugs or feature requests to "bug-moosex-autodestruct at rt.cpan.org", or through the web interface at . AUTHOR Chris Weyl COPYRIGHT AND LICENSE This software is Copyright (c) 2011 by Chris Weyl. This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999