--- /dev/null
+MooseX-Attribute-Cached
+
+This is an extension for your Moose based classes to make your attributes
+set and get their values from a cache system, rather than from the default
+perl memory perl instance storage. That way:
+
+ 1) All instances share the same attribute slot. Updates made by one
+ attribute are seen by all instances, even on different servers as long as
+ they share a distributed caching system (such as Memcached).
+
+ 2) It can be a sort of 'persistance lite' although I highly recommend using
+ a real persistance system, such as a database or MooseX::Storage.
+
+ 3) You could probably use this as a sort of expensive class attribute, but
+ you will likely be more happy with MooseX::ClassAttribute
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the
+perldoc command.
+
+ perldoc MooseX::Attribute::Cached
+
+You can also look for information at:
+
+ RT, CPAN's request tracker
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Attribute-Cached
+
+ AnnoCPAN, Annotated CPAN documentation
+ http://annocpan.org/dist/MooseX-Attribute-Cached
+
+ CPAN Ratings
+ http://cpanratings.perl.org/d/MooseX-Attribute-Cached
+
+ Search CPAN
+ http://search.cpan.org/dist/MooseX-Attribute-Cached
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2008 John Napiorkowski
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
--- /dev/null
+ ## 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/
+\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
--- /dev/null
+package MooseX::Attribute::Cached;
+
+use Moose;
+
+=head1 NAME
+
+MooseX::Attribute::Cached; Cache your Moose Attribute Value
+
+=head2 AUTHORITY
+
+cpan:JJNAPIORK
+
+=cut
+
+our $AUTHORITY = 'cpan:JJNAPIORK';
+
+=head1 VERSION
+
+Version 0.01
+
+=cut
+
+our $VERSION = '0.01';
+
+=head1 SYNOPSIS
+
+ package MyApp;
+
+ use Moose;
+ with 'MooseX::Attribute::Cached.pm';
+
+ ## 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'],
+ storage_key=>'something_different_shared_key_2',
+ %other_attribute_options_2,
+ );
+
+ ## Here's the provider for the attributes storage. Basically you need to
+ ## return the storage provider name and it's instantiation args.
+ 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;
+
+=head1 DESCRIPTION
+
+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 instances with access to the same cache will share and
+update a common value. That way:
+
+1) All instances share the same attribute slot. Updates made by one
+attribute are seen by all instances, even on different servers as long as
+they share a distributed caching system (such as Memcached).
+
+2) It can be a sort of 'persistance lite' although I highly recommend using
+a real persistance system, such as a database or L<MooseX::Storage>.
+
+3) You could probably use this as a sort of expensive class attribute, but
+you will likely be more happy with L<MooseX::ClassAttribute>
+
+At this time, this supports two Cachings systems, Memcached and FastMmap. If
+you have need for other cache types, adding a driver for it should be easy, so
+please send your patches and test cases.
+
+=head1 AUTHOR
+
+John Napiorkowski, C<< <john.napiorkowski at takkle.com> >>
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc MooseX::Attributes::Cached
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Attributes-Cached>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/MooseX-Attributes-Cached>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/MooseX-Attributes-Cached>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/MooseX-Attributes-CachedF>
+
+=back
+
+=head1 SEE ALSO
+
+L<Moose>, L<MooseX::ClassAttribute>, L<MooseX::Storage>, L<Cache::FastMmap>,
+L<Cache::Memcached>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008 John Napiorkowski, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+no Moose; 1; # End of MooseX::Attributes::Cached