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); } } }
public function incrementBuySideHourlyImpressionsByTLDCached($config, $banner_id, $tld) { $params = array(); $params["InsertionOrderLineItemID"] = $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 { /* * 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 \util\CachedStatsWrites::increment_cached_write_result_int_apc($config, $params, $class_dir_name, 1); // SYNCHRONIZED BLOCK END \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name); if ($current != null) { $bucket_value = $current["value"]; // write out value $this->incrementBuySideHourlyImpressionsByTLD($banner_id, $tld, $bucket_value); } } }
public function incrementPrivateExchangeRtbChannelDailyStatsCached($config, $method_params) { $publisher_website_id = $method_params["publisher_website_id"] = $method_params["rtb_channel_site_id"]; $rtb_channel_site_name = $method_params["rtb_channel_site_name"]; $impressions_offered_counter = $method_params["impressions_offered_counter"]; $auction_bids_counter = $method_params["auction_bids_counter"]; $spend_offered_in_bids = $method_params["spend_offered_in_bids"]; $floor_price_if_any = $method_params["floor_price_if_any"]; $params = array(); $class_dir_name = 'PrivateExchangeRtbChannelDailyStats'; $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_private_exchange_channel_stats($config, $params, $class_dir_name, $method_params); } 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 \util\CachedStatsWrites::increment_cached_write_result_private_exchange_channel_stats($config, $params, $class_dir_name, $method_params); // SYNCHRONIZED BLOCK END \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name); if ($current != null) { // write out values $this->incrementPrivateExchangeRtbChannelDailyStats($config, $current); } } }