PHP Classes

File: src/PHPVideoToolkit/CacheAbstract.php

Recommend this page to a friend!
  Classes of Oliver Lillie   PHP Video Toolkit   src/PHPVideoToolkit/CacheAbstract.php   Download  
File: src/PHPVideoToolkit/CacheAbstract.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Video Toolkit
Manipulate and convert videos with ffmpeg program
Author: By
Last change: Update CacheAbstract.php

Removed the line abstract public function isAvailable(); to get rid of known issue on PHP 5.3.0 https://bugs.php.net/bug.php?id=43200
added a poor mans cacher
updated version in source
Date: 1 year ago
Size: 1,835 bytes
 

Contents

Class file image Download
<?php
   
   
/**
     * This file is part of the PHP Video Toolkit v2 package.
     *
     * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
     * @license Dual licensed under MIT and GPLv2
     * @copyright Copyright (c) 2008-2014 Oliver Lillie <http://www.buggedcom.co.uk>
     * @package PHPVideoToolkit V2
     * @version 2.1.7-beta
     * @uses ffmpeg http://ffmpeg.sourceforge.net/
     */
    
   
namespace PHPVideoToolkit;

   
/**
     * @access public
     * @author Oliver Lillie
     * @package default
     */
   
abstract class CacheAbstract implements CacheInterface
   
{
        protected
$_config;

        protected
$_key_prefix = 'phpvideotoolkit_v2';
       
        public function
__construct(Config $config=null)
        {
           
$this->_config = $config === null ? Config::getInstance() : $config;
            if(
$this->isAvailable() === false)
            {
               
$class_name = get_class($this);
                throw new
Exception('The cache driver `'.substr($class_name, strrpos($class_name, '_')+1).'` is not available on your system.');
            }
        }
       
        public function
set($key, $value, $expiration=null)
        {
           
$this->_cache[$key] = $value;
           
            return
$this->_set($this->_key_prefix.'_'.$key, $value, $expiration);
        }
       
        public function
get($key, $default_value=null)
        {
           
$key = $this->_key_prefix.'_'.$key;
           
            if(
$this->_isMiss($key) === true)
            {
                return
$default_value;
            }
            return
$this->_get($key);
        }

        abstract protected function
_get($key);

        abstract protected function
_isMiss($key);

        abstract protected function
_set($key, $value, $expiration=null);
    }