add cache search here if ( !empty( $this->dim_cache[ $one['year'].$one['day_of_year'] ] ) ) { $dim_time = $this->dim_cache[ $one['year'].$one['day_of_year'] ]; } if ( empty($dim_time) ) { $dim_time = $this->find('first',array( 'conditions' => array( 'DimensionTime.day_of_year' => $one['day_of_year'], 'DimensionTime.year' => $one['year'] ) )); } if ( empty($dim_time) ) { $dim_time['DimensionTime'] = array( 'day_of_week'=> $one['day_of_week'], 'day_of_month'=> $one['day_of_month'], 'day_of_year'=> $one['day_of_year'], 'month'=> $one['month'], 'quarter'=> $one['quarter'], 'year'=> $one['year'], 'holiday'=> -1, 'weekend'=> ($one['day_of_week']>5) ? 1: 0, ); $this->create($dim_time); $this->save($dim_time); $dim_time = $this->read(); } //-> save to cache here $this->dim_cache[ $one['year'].$one['day_of_year'] ] = $dim_time; return $dim_time['DimensionTime']['id']; } } ?>