Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 408395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:41:17+00:00 2026-05-12T17:41:17+00:00

I have a set of rather complex ORM modules that inherit from Class::DBI .

  • 0

I have a set of rather complex ORM modules that inherit from Class::DBI. Since the data changes quite infrequently, I am considering using a Caching/Memoization layer on top of this to speed things up. I found a module: Class::DBI::Cacheable but no rating or any reviews on RT. I would appreciate hearing from people who have used this or any other Class::DBI caching scheme.

Thanks a ton.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:41:17+00:00Added an answer on May 12, 2026 at 5:41 pm

    I too have rolled my own ORM plenty of times I hate to say! Caching/Memoization is pretty easy if all your fetches happen through a single api (or subclasses thereof).

    For any fetch based on a unique key you can just cache based on a concatenation of the keys. A naive approach might be:

    my %_cache;
    
    sub get_object_from_db {
        my ($self, $table, %table_lookup_key) = @_;
    
        # concatenate a unique key for this object
        my $cache_key = join('|', map { "$_|$table_lookup_key{$_}" }
                           sort keys %table_lookup_key
    
        return $_cache{$cache_key}
            if exists $_cache{$cache_key};
    
        # otherwise get the object from the db and cache it in the hash
        # before returning
    }
    

    Instead of a hash, you can use the Cache:: suite of modules on CPAN to implement time and memory limits in your cache.

    If you’re going to cache for some time you might want to think about a way to expire objects in the cache. If for instance all your updates also go through the ORM you can clear (or update) the cache entry in your update() ORM method.

    A final point to think carefully about – you’re returning the same object each time which has implications. If, eg., one piece of code retrieves an object and updates a value but doesn’t commit that change to the db, all other code retrieving that object will see that change. This can be very useful if you’re stringing together a series of operations – they can all update the object and then you can commit it at the end – but it may not be what you intend. I usually set a flag on the object when it is fresh from the database and then in your setter method invalidate that flag if the object is updated – that way you can always check that flag if you really want a fresh object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 346k
  • Answers 346k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SharePoint's lists are not really relational data, and therefore the… May 14, 2026 at 6:08 am
  • Editorial Team
    Editorial Team added an answer The sweden object specifies the CET time zone by default… May 14, 2026 at 6:08 am
  • Editorial Team
    Editorial Team added an answer For part 1, findstr is the answer. You can just… May 14, 2026 at 6:08 am

Related Questions

I am in the processes of replacing the framework for a fairly complex business
I've been spending some time refactoring my C# code, and I'm struck by how
I have to write a very large test suite for a complex set of
I have a rather complex ListView, with variable list item heights. Under certain conditions,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.