logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

DBIx::Class::Cursor::Cached - cursor class with built-in caching support

Author

       Matt S Trout <mst@shadowcat.co.uk> http://www.shadowcat.co.uk/

       Initial development sponsored by and (c) Takkle, Inc. 2007

License

       This library is free software under the same license as perl itself

perl v5.38.2                                       2024-03-05                   DBIx::Class::Cursor::Cached(3pm)

Name

       DBIx::Class::Cursor::Cached - cursor class with built-in caching support

Synopsis

         my $schema = SchemaClass->connect(
           $dsn, $user, $pass, { cursor_class => 'DBIx::Class::Cursor::Cached' }
         );

         $schema->default_resultset_attributes({
           cache_object => Cache::FileCache->new({ namespace => 'SchemaClass' }),
         });

         my $rs = $schema->resultset('CD')->search(undef, { cache_for => 300 });

         my @cds = $rs->all; # fills cache

         $rs = $schema->resultset('CD')->search(undef, { cache_for => 300 });
           # refresh resultset

         @cds = $rs->all; # uses cache, no SQL run

         $rs->cursor->clear_cache; # deletes data from cache

         @cds = $rs->all; # refills cache

See Also