GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CATALYST::MODEL::MEMCACHED (3)

.ds Aq ’

NAME

Catalyst::Model::Memcached - Wrapper for memcached imitating Catalyst models

CONTENTS

SYNOPSIS



  package 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;



DESCRIPTION

Simple Model for Catalyst for storing data in memcached

USAGE

<B>WarningB> 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

create( hashref )


  $c->model( Cached::Token )->create(
    { token => aaaa, signature => abcd }
  );



Creates record in memcached with key = primary_key, data = hashref, expire = ttl. hashref must contains primary_key.

search( hashref )


  $c->model( Cached::Token )->search( { token => aaaa } );



Searches data in memcached by primary_key key and returns memcached answer. hashref must contains primary_key.

find( hashref ) The same as search.
find_or_new( hashref ) Calls find, if nothing found - calls create.
delete( hashref ) Delete record with primary_key.

AUTHOR



    Denis Pokataev
    CPAN ID: CATONE
    Sponsored by Openstat.com
    catone@cpan.org



COPYRIGHT

This 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 ALSO

Catalyst, Cache::Memcached::Fast, perl(1).
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CATALYST::MODEL::MEMCACHED (3) 2010-03-23

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.