<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Cf_Cache_file extends CI_Cache_file
{
    protected function _get($id)
    {
        if (!is_file($this->_cache_path . $id)) {
            return false;
        }

        $data = @file_get_contents($this->_cache_path . $id);
        if ($data === false) {
            return false;
        }

        $data = unserialize($data);
        if (!is_array($data)) {
            return false;
        }

        if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl']) {
            @unlink($this->_cache_path . $id);
            return false;
        }

        return $data;
    }
}
