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