You are here

public function CampaignMonitorManager::removeSubscriberFromCache in Campaign Monitor 8.2

Remove subscribers from local cache.

This forces the data to be fetched from Campaign Monitor at the next request. This function should be used in connection with updating subscriber information.

Parameters

mixed $listId: The unique Campaign Monitor list ID.

mixed $email: The e-mail address to be removed from cache.

3 calls to CampaignMonitorManager::removeSubscriberFromCache()
CampaignMonitorManager::subscribe in src/CampaignMonitorManager.php
Subscribe a user to a given list, with information entered.
CampaignMonitorManager::unsubscribe in src/CampaignMonitorManager.php
Unsubscribe a given user, identified by e-mail address, from a given list.
CampaignMonitorManager::updateSubscriberEmail in src/CampaignMonitorManager.php
Updates the subscriber e-mail address for a given list.

File

src/CampaignMonitorManager.php, line 970

Class

CampaignMonitorManager
Manager for Campaignmonitor.

Namespace

Drupal\campaignmonitor

Code

public function removeSubscriberFromCache($listId, $email) {
  if (($cache = $this->cacheBackend
    ->get('campaignmonitor_subscribers')) && !empty($cache->data)) {

    // Cache information found.
    $this->subscribers = $cache->data;
    if (isset($this->subscribers[$listId . $email])) {

      // Subscriber found in the cache, so remove it.
      unset($this->subscribers[$listId . $email]);
      $this->cacheBackend
        ->set('campaignmonitor_subscribers', $this->subscribers, $this
        ->getCacheTimeout());
    }
  }
}