You are here

function brightcove_cache_set in Brightcove Video Connect 7.3

Same name and namespace in other branches
  1. 7.7 brightcove.module \brightcove_cache_set()
  2. 7.4 brightcove.module \brightcove_cache_set()
  3. 7.5 brightcove.module \brightcove_cache_set()
  4. 7.6 brightcove.module \brightcove_cache_set()

Cache Brightcove data according to the type of caching being set.

Parameters

$cid: The id of the cache.

$data: The data going to be cached .

Return value

mixed The cached data, if exists, NULL otherwise.

6 calls to brightcove_cache_set()
brightcove_get_playlists in ./brightcove.playlist.inc
Get the playlists from Brightcove.
brightcove_playlist_load in ./brightcove.module
brightcove_status in ./brightcove.module
Return the status of a specific video.
brightcove_video_load in ./brightcove.module
Loads Brightcove video from BC Media API. Uses a 5 minutes cache to speed up lookups.
_brightcove_field_playlist_browse in brightcove_field/brightcove_field.playlist.inc

... See full list

File

./brightcove.module, line 1236
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_cache_set($cid, $data) {

  // If cache is enabled.
  if (variable_get('brightcove_cache_enabled', TRUE)) {

    // Get the type of cache being set.
    $type = variable_get('brightcove_cache_type', 'db');
    switch ($type) {
      case 'db':

        // Get type related settings.
        $cache_settings = variable_get('brightcove_cache_db', array());
        $cache_time = isset($cache_settings['cache_time']) ? $cache_settings['cache_time'] : 600;

        // Save data to cache table.
        cache_set($cid, $data, 'cache_brightcove', time() + $cache_time);
        break;
      case 'file':
      case 'memcached':
        $bc_cache = brightcove_cache_initialize();
        $bc_cache
          ->set($cid, $data);
        break;
    }
  }
}