IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24347


Ignore:
Timestamp:
Jun 5, 2009, 4:08:32 PM (17 years ago)
Author:
jhoblitt
Message:

add basic valid key caching via memcached

Location:
trunk/Nebulous-Server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Build.PL

    r23932 r24347  
    1010    requires            => {
    1111        'Apache2::Const'        => 0,
     12        'Cache::Memcached::Managed' => '0.20',
    1213        'Class::Accessor::Fast' => 0,
    1314        'Config::YAML'          => '1.42',
  • trunk/Nebulous-Server/Changes

    r24304 r24347  
    22
    330.17
     4    - add basic valid key caching via memcached
    45    - add params checking to Nebulous::Key::parse_neb_key()
    56    - restrict creation/modification/remove of xattrs to the user.* namespace
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r24337 r24347  
    2727use Params::Validate qw( validate validate_pos SCALAR SCALARREF UNDEF BOOLEAN );
    2828use URI::file;
    29 
    30 __PACKAGE__->mk_accessors(qw( log sql config ));
     29use Cache::Memcached::Managed;
     30
     31__PACKAGE__->mk_accessors(qw( log sql config cache ));
    3132
    3233use constant SUBPATH_DEPTH  => 2;
     
    6263    $self->sql($sql);
    6364    $self->config($config);
    64 
     65    $self->cache(Cache::Memcached::Managed->new($config->memcached));
    6566    $log->debug( "leaving" );
    6667
     
    15771578            # remove it too
    15781579            if ( $instances == 1 ) {
     1580                # remove key from cache
     1581                $self->cache->delete($key->path);
     1582
    15791583                # we just removed the last instance
    15801584                my $query = $db->prepare_cached( $sql->delete_object );
     
    18951899    $log->logdie("$@") if $@;
    18961900
     1901    # check cache first
     1902    my $cached = $self->cache->get($key->path);
     1903    if (defined $cached) {
     1904        $log->debug( "key $key found in cache" );
     1905        $log->debug( "leaving" );
     1906        return 1;
     1907    } else {
     1908        $log->debug( "key $key not found in cache" );
     1909    }
     1910
    18971911    my $db  = $self->db($key);
    18981912
     
    19111925
    19121926    if (defined $ext_id) {
    1913         $log->debug( "key is valid" );
     1927        $log->debug( "key found in db" );
    19141928        $log->debug( "leaving" );
    19151929        return 1;
    19161930    }
    19171931
    1918     $log->debug( "key not found" );
     1932    $log->debug( "key not found in db" );
    19191933    $log->debug( "leaving" );
    19201934
  • trunk/Nebulous-Server/lib/Nebulous/Server/Config.pm

    r23932 r24347  
    4949    dbuser      => { type => SCALAR, optional => 1 },
    5050    dbpasswd    => { type => SCALAR, optional => 1 },
     51    memcached   => { type => SCALAR, default => '127.0.0.1:11311' },
    5152};
    5253
Note: See TracChangeset for help on using the changeset viewer.