WordPress.org

Making WordPress.org


Ignore:
Timestamp:
02/18/2017 10:11:43 PM (3 years ago)
Author:
ocean90
Message:

Translate: Don't clear the project caches manually, instead use the last_changed value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/inc/class-plugin.php

    r4929 r4931  
    432432     */
    433433    public function get_sub_project_ids( $project_id ) {
    434         $cache_key = 'project:' . $project_id . ':childs';
     434        $last_changed = wp_cache_get_last_changed( self::$cache_group );
     435
     436        $cache_key = 'project:' . $project_id . ':childs:' . $last_changed;
    435437        $cache = wp_cache_get( $cache_key, self::$cache_group );
    436438        if ( false !== $cache ) {
     
    480482
    481483    /**
    482      * Removes all of the project ids from the cache.
     484     * Updates `last_changed` value for the cache group.
    483485     */
    484486    public function clear_project_cache() {
    485487        wp_cache_set( 'last_changed', microtime(), self::$cache_group );
    486 
    487         $projects = $this->get_all_projects();
    488 
    489         foreach ( $projects as $project ) {
    490             $cache_key = 'project:' . $project->id . ':childs';
    491             wp_cache_delete( $cache_key, self::$cache_group );
    492         }
    493488    }
    494489
Note: See TracChangeset for help on using the changeset viewer.