WordPress.org

WordPress MU

Changeset 2027


Ignore:
Timestamp:
12/14/09 17:38:18 (4 years ago)
Author:
donncha
Message:

Use transients for dirsize cache rather than blog options, props jamescollins, see #1175

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wpmu-functions.php

    r2026 r2027  
    16621662 
    16631663function get_dirsize( $directory ) { 
    1664     $dirsize = get_option( 'dirsize_cache' ); 
    1665     if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) && $dirsize[ $directory ][ 'age' ] > time() - 3600 ) { 
     1664    $dirsize = get_transient( 'dirsize_cache' ); 
     1665    if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) { 
    16661666        return $dirsize[ $directory ][ 'size' ]; 
    16671667    } 
     
    16701670    } 
    16711671    $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory ); 
    1672     $dirsize[ $directory ][ 'age' ] = time(); 
    1673  
    1674     update_option( 'dirsize_cache', $dirsize ); 
     1672 
     1673    set_transient( 'dirsize_cache', $dirsize, 3600 ); 
    16751674    return $dirsize[ $directory ][ 'size' ]; 
    16761675} 
    16771676 
    16781677function clear_dirsize_cache( $file = true ) { 
    1679     delete_option( 'dirsize_cache' ); 
     1678    delete_transient( 'dirsize_cache' ); 
    16801679    return $file; 
    16811680} 
Note: See TracChangeset for help on using the changeset viewer.