Beispiel #1
0
 public static function incrementLineItemBidFrequencyCount($config, $InsertionOrderLineItemID, $reset = false)
 {
     $params = array();
     $params["InsertionOrderLineItemID"] = $InsertionOrderLineItemID;
     $class_dir_name = 'FrequencyHelper';
     // WAIT FOR SYNCHRONIZED LOCK TO BE FREED
     \util\CacheSql::wait_for_reset_lock($config, $params, $class_dir_name);
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists && $reset === false) {
         // increment bucket
         self::increment_frequency_impressions_counter($config, $params, $class_dir_name, 1);
     } else {
         /*
          * DO THIS BEFORE APC RESET OPERATIONS TO AVOID THREAD-LIKE DUPLICATION DUE TO THE LACK OF
          * A SYNCHRONIZED KEYWORD IN PHP
          */
         // SYNCHRONIZED BLOCK START
         \util\CacheSql::create_reset_write_lock($config, $params, $class_dir_name);
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, $class_dir_name);
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         self::increment_frequency_impressions_counter($config, $params, $class_dir_name, 1);
         // SYNCHRONIZED BLOCK END
         \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name);
     }
 }
 public static function incrementPublisherBidsCounterCached($config, \model\PublisherHourlyBids $PublisherHourlyBids)
 {
     $params = array();
     $params["PublisherAdZoneID"] = $PublisherHourlyBids->PublisherAdZoneID;
     $class_dir_name = 'PublisherHourlyBids';
     // WAIT FOR SYNCHRONIZED LOCK TO BE FREED
     \util\CacheSql::wait_for_reset_lock($config, $params, $class_dir_name);
     $cached_key_exists = \util\CacheSql::does_cached_write_exist_apc($config, $params, $class_dir_name);
     if ($cached_key_exists) {
         // increment bucket
         self::increment_cached_write_result_publisher_bids_apc($config, $params, $class_dir_name, $PublisherHourlyBids);
     } else {
         /*
          * DO THIS BEFORE APC RESET OPERATIONS TO AVOID THREAD-LIKE DUPLICATION DUE TO THE LACK OF
          * A SYNCHRONIZED KEYWORD IN PHP
          */
         // SYNCHRONIZED BLOCK START
         \util\CacheSql::create_reset_write_lock($config, $params, $class_dir_name);
         // get value sum from apc
         $current = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_dir_name);
         // delete existing key - reset bucket
         \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name);
         // increment bucket
         self::increment_cached_write_result_publisher_bids_apc($config, $params, $class_dir_name, $PublisherHourlyBids);
         // SYNCHRONIZED BLOCK END
         \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name);
         if ($current != null) {
             // write out values
             $PublisherHourlyBids->AuctionCounter = $current["AuctionCounter"];
             $PublisherHourlyBids->BidsWonCounter = $current["BidsWonCounter"];
             $PublisherHourlyBids->BidsLostCounter = $current["BidsLostCounter"];
             $PublisherHourlyBids->BidsErrorCounter = $current["BidsErrorCounter"];
             $PublisherHourlyBids->SpendTotalGross = floatval($current["SpendTotalGross"]);
             $PublisherHourlyBids->SpendTotalNet = floatval($current["SpendTotalNet"]);
             self::incrementPublisherBidsCounter($PublisherHourlyBids);
         }
     }
 }