public function incrementAdCampaignBannerImpressionsCounterAndSpendCached($config, $buyer_id, $banner_id, $impression_cost_gross, $impression_cost_net) { $params = array(); $params["BuySidePartnerID"] = $buyer_id; $params["AdCampaignBannerID"] = $banner_id; $class_dir_name = 'BuySideHourlyImpressionsCounterCurrentSpend'; $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_impressions_spend_apc($config, $params, $class_dir_name, 1, $impression_cost_gross, $impression_cost_net); } else { // get value sum from apc $current = \util\CacheSql::get_cached_read_result_apc($config, $params, $class_dir_name); if ($current != null) { $bucket_impressions = $current["impressions"]; $bucket_spend_gross = $current["spend_gross"]; $bucket_spend_net = $current["spend_net"]; // write out values $this->incrementAdCampaignBannerImpressionsCounterAndSpend($buyer_id, $banner_id, $bucket_impressions, $bucket_spend_gross, $bucket_spend_net); } // delete existing key - reset bucket \util\CacheSql::delete_cached_write_apc($config, $params, $class_dir_name); // increment bucket \util\CachedStatsWrites::increment_cached_write_result_impressions_spend_apc($config, $params, $class_dir_name, 1, $impression_cost_gross, $impression_cost_net); } }
public function incrementInsertionOrderLineItemImpressionsCounterAndSpendCached($config, $buyer_id, $banner_id, $impression_cost_gross, $impression_cost_net) { $params = array(); $params["BuySidePartnerID"] = $buyer_id; $params["InsertionOrderLineItemID"] = $banner_id; $class_dir_name = 'BuySideHourlyImpressionsCounterCurrentSpend'; $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_impressions_spend_apc($config, $params, $class_dir_name, 1, $impression_cost_gross, $impression_cost_net); } 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_impressions_spend_apc($config, $params, $class_dir_name, 1, $impression_cost_gross, $impression_cost_net); // SYNCHRONIZED BLOCK END \util\CacheSql::reset_write_unlock($config, $params, $class_dir_name); if ($current != null) { $bucket_impressions = $current["impressions"]; $bucket_spend_gross = $current["spend_gross"]; $bucket_spend_net = $current["spend_net"]; // write out values $this->incrementInsertionOrderLineItemImpressionsCounterAndSpend($buyer_id, $banner_id, $bucket_impressions, $bucket_spend_gross, $bucket_spend_net); } } }