---
name: "Jifty::DBI::Record::Cachable"
section: "3pm"
platform: "linux"
package: "libjifty-dbi-perl"
version: "0.78-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Jifty::DBI::Record::Cachable"
---

# Jifty::DBI::Record::Cachable(3pm)

records with caching behavior

## NAME

Jifty::DBI::Record::Cachable - records with caching behavior

## SYNOPSIS

```
  package Myrecord;
  use base qw/Jifty::DBI::Record::Cachable/;
```

## DESCRIPTION

This module subclasses the main Jifty::DBI::Record package to add a caching layer.

The public interface remains the same, except that records which have been loaded in the last few seconds may be reused by subsequent fetch or load methods without retrieving them from the database.

## METHODS

### flush\_cache

This class method flushes the \_global\_ Jifty::DBI::Record::Cachable  cache.  All caches are immediately expired.

### \_flush\_key\_cache

Blow away this record type's key cache

### load\_from\_hash

Overrides the implementation from Jifty::DBI::Record to add caching.

### load\_by\_cols

Overrides the implementation from Jifty::DBI::Record to add caching.

### \_cache\_config

You can override this method to change the duration of the caching from the default of 5 seconds.

For example, to cache records for up to 30 seconds, add the following method to your class:

```
  sub _cache_config {
      { 'cache_for_sec' => 30 }
  }
```

## AUTHOR

Matt Knopp \<mhat@netlag.com\>

## SEE ALSO

Jifty::DBI, Jifty::DBI::Record
