private static function checkHoneyPotCached($config, $remote_ip) { $params = array(); $params["remote_ip"] = $remote_ip; $boolean_result = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, self::$class_name); return $boolean_result; }
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); } }
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); } } }
public static function increment_cached_write_result_ssp_rtb_channel_stats($config, $params, $class_name, $method_params) { $buyside_partner_name = $method_params["buyside_partner_name"]; $rtb_channel_site_id = $method_params["rtb_channel_site_id"]; $rtb_channel_site_name = $method_params["rtb_channel_site_name"]; $rtb_channel_site_domain = $method_params["rtb_channel_site_domain"]; $rtb_channel_site_iab_category = $method_params["rtb_channel_site_iab_category"]; $rtb_channel_publisher_name = $method_params["rtb_channel_publisher_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"]; $current = \util\CacheSql::get_cached_read_result_apc_type_convert($config, $params, $class_name); if ($current !== null) { if (isset($current[$rtb_channel_site_id])) { $existing_impressions_offered_counter = intval($current[$rtb_channel_site_id]["impressions_offered_counter"]); $impressions_offered_counter += $existing_impressions_offered_counter; $current[$rtb_channel_site_id]["impressions_offered_counter"] = intval($impressions_offered_counter); $existing_auction_bids_counter = floatval($current[$rtb_channel_site_id]["auction_bids_counter"]); $auction_bids_counter += $existing_auction_bids_counter; $current[$rtb_channel_site_id]["auction_bids_counter"] = intval($auction_bids_counter); $existing_spend_offered_in_bids = floatval($current[$rtb_channel_site_id]["spend_offered_in_bids"]); $spend_offered_in_bids += $existing_spend_offered_in_bids; $current[$rtb_channel_site_id]["spend_offered_in_bids"] = floatval($spend_offered_in_bids); } else { $current[$rtb_channel_site_id] = $method_params; } } else { $current = array(); $current[$rtb_channel_site_id] = $method_params; } // 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, $current, 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); } }