public function getPerTimeCached($config, $where_params = null, $time_to_live = 900, $refresh = false, $is_admin = FALSE)
 {
     $cached_data = \util\CacheSql::get_cached_read_result_apc($config, $where_params, $this->table . '_M');
     if ($cached_data !== null && !$refresh) {
         if ($cached_data == self::$empty_array_value) {
             return array();
         } else {
             return $cached_data;
         }
     } else {
         $data = $this->getPerTime($where_params, $is_admin);
         \util\CacheSql::put_cached_read_result_apc($config, $where_params, $this->table . '_M', $data, $time_to_live);
         return $data;
     }
 }
Beispiel #2
0
 public function incrementBuySideHourlyImpressionsByTLDCached($config, $banner_id, $tld)
 {
     $params = array();
     $params["AdCampaignBannerID"] = $banner_id;
     $params["PublisherTLD"] = $tld;
     $class_dir_name = 'BuySideHourlyImpressionsByTLD';
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists) {
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
     } else {
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_dir_name);
         if ($current != null) {
             $bucket_value = $current["value"];
             // write out value
             $this->incrementBuySideHourlyImpressionsByTLD($banner_id, $tld, $bucket_value);
         }
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1);
     }
 }
 public static function increment_cached_write_result_int_apc($config, $params, $class_name, $value, $ttl = 60)
 {
     $current = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_name);
     if ($current !== null) {
         $existing_value = intval($current["value"]);
         $value += $existing_value;
     }
     // cache up to 1 hour, the write the the db should occur before that.
     \util\CacheSql::put_cached_read_result_apc($config, $params, $class_name, array("value" => intval($value)), 3600);
     $timer_name = 'write_timer';
     $write_timer = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_name . $timer_name);
     if ($write_timer == null) {
         /*
          * 60 second write timer, when the apc cache value is gone the
          * contents are written the DB and the apc value is cleared
          */
         \util\CacheSql::put_cached_read_result_apc($config, $params, $class_name . $timer_name, array($timer_name => true), 60);
     }
 }
 private static function checkScoreCached($config, $page_to_check)
 {
     $params = array();
     $params["PageURL"] = $page_to_check;
     $json_result = \util\CacheSql::get_cached_read_result_apc($config, $params, self::$class_name);
     return $json_result;
 }
Beispiel #5
0
 protected static function increment_frequency_impressions_counter($config, $params, $class_name, $increment_amount = 1)
 {
     $current = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, $class_name);
     if ($current !== null) {
         $existing_impressions_counter = intval($current["ImpressionsCounter"]);
         $existing_impressions_counter += $increment_amount;
     } else {
         $existing_impressions_counter = $increment_amount;
     }
     // cache up to 1 hour, the write the the db should occur before that.
     \util\CacheSql::put_cached_read_result_apc($config, $params, $class_name, array("ImpressionsCounter" => $existing_impressions_counter), 3600);
     $timer_name = 'write_timer';
     $write_timer = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_name . $timer_name);
     if ($write_timer == null) {
         /*
          * 60 second write timer, when the apc cache value is gone the
          * contents are written the DB and the apc value is cleared
          */
         \util\CacheSql::put_cached_read_result_apc($config, $params, $class_name . $timer_name, array($timer_name => true), 60);
     }
 }