|
NAMECatalyst::Model::Memcached - Wrapper for memcached imitating Catalyst modelsSYNOPSISpackage MyCatalyst::Model::Token; use Moose; use namespace::autoclean; BEGIN { extends 'Catalyst::Model::Memcached' }; __PACKAGE__->config( args => { servers => [ '127.0.0.1:11211' ], namespace => 'db' } ); # Alternatively, this could be specified through config file __PACKAGE__->set_primary_key( qw/token/ ); __PACKAGE__->set_ttl( 300 ); sub BUILD { my $self = shift; $self->{__once_initialized_object} = Object->new; return $self; } sub create { my ($self, $hash) = @_; $hash->{token} = $self->{__once_initialized_object}->create_id(); return $self->SUPER::create($hash) } 1; DESCRIPTIONSimple Model for Catalyst for storing data in memcachedUSAGEWarning Module requires perl >= 5.10 and Catalyst >= 5.8 !One subclass of model handle one set of primary_key and ttl params. You can think of it as one table in regular DB. In case you want to use memcached to store different entities through this model, you can configure it like this in config file: Model: Cached: class: MyApp::Store::Cached config: args: servers: - 127.0.0.1:11211 namespace: 'db.' ttl: 86400 Assuming your model class is named MyApp::Model::Cached, your memcached server is started on localhost on port 11211. With this configuration all classes MyApp::Store::Cached::* will be loaded with same memcached configuration and default ttl of 86400. Primary key could be the same in different classes - to avoid clashes keys that are stored in memcached are constructed like 'global_namespace.last_part_of_module_name.primary_key'. METHODS
AUTHORDenis Pokataev CPAN ID: CATONE Sponsored by Openstat.com catone@cpan.org COPYRIGHTThis program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.The full text of the license can be found in the LICENSE file included with this module. SEE ALSOCatalyst, Cache::Memcached::Fast, perl(1).
Visit the GSP FreeBSD Man Page Interface. |