## MooseX::Attribute::Cached; Store the value of your Moose Attributes in a ## cached storage. The purpose of this is to faciliate sharing of attribute ## values over various processes or every across machines, presuming you are ## using a distributed cache, like Memcached. All instance with access to ## the same cache will share and update a common value. ## Proposed Directory Structure MooseX/ Attribute/ Cached.pm Cached/ Storage.pm Storage/ FastMmap.pm Memcached.pm Meta/ Attribute/ Trait/ Cached.pm ## Example application and syntax usage package MyApp; use Moose; with 'MooseX::Attribute::Cached'; ## Cache Storage Options Declared Manually has 'shared_key_1' => ( traits => ['Cached'], cache_storage => ['Memcached' => { 'servers' => [ "10.0.0.15:11211", "10.0.0.15:11212"], }], %other_attribute_options_1, ); ## This attribute get's it's cache storage from a method, which can be ## called from a lazy attribute or as a package method has 'shared_key_2' => ( traits => ['Cached'], %other_attribute_options_2, ); ## Here's the provider for the attributes storage sub _cache_storage_options_shared_key_2 { ## If the calling attribute is lazy get's $self, otherwise we ## gets __PACKAGE__. Getting $self could be useful if you are reading ## the cache options from something like your config object, etc. my $self = shift @_; return [ 'Memcached' => { 'servers' => [ "10.0.0.15:11211", "10.0.0.15:11212", "/var/sock/memcached", "10.0.0.17:11211", [ "10.0.0.17:11211", 3 ], ], 'debug' => 0, 'compress_threshold' => 10_000, }, ]; } ## Rest of your Class Definition 1;