Base64.php
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
namespace Phalcon\Cache\Frontend {
/**
* Phalcon\Cache\Frontend\Base64
*
* Allows to cache data converting/deconverting them to base64.
*
* This adapters uses the base64_encode/base64_decode PHP's functions
*
*<code>
*
* // Cache the files for 2 days using a Base64 frontend
* $frontCache = new Phalcon\Cache\Frontend\Base64(array(
* "lifetime" => 172800
* ));
*
* //Create a MongoDB cache
* $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array(
* 'server' => "mongodb://localhost",
* 'db' => 'caches',
* 'collection' => 'images'
* ));
*
* // Try to get cached image
* $cacheKey = 'some-image.jpg.cache';
* $image = $cache->get($cacheKey);
* if ($image === null) {
*
* // Store the image in the cache
* $cache->save($cacheKey, file_get_contents('tmp-dir/some-image.jpg'));
* }
*
* header('Content-Type: image/jpeg');
* echo $image;
*</code>
*/
class Base64 implements \Phalcon\Cache\FrontendInterface {
protected $_frontendOptions;
/**
* \Phalcon\Cache\Frontend\Base64 constructor
*
* @param array $frontendOptions
*/
public function __construct($frontendOptions=null){ }
/**
* Returns the cache lifetime
*
* @return integer
*/
public function getLifetime(){ }
/**
* Check whether if frontend is buffering output
*
* @return boolean
*/
public function isBuffering(){ }
/**
* Starts output frontend. Actually, does nothing
*/
public function start(){ }
/**
* Returns output cached content
*
* @return string
*/
public function getContent(){ }
/**
* Stops output frontend
*/
public function stop(){ }
/**
* Serializes data before storing them
*
* @param mixed $data
* @return string
*/
public function beforeStore($data){ }
/**
* Unserializes data after retrieval
*
* @param mixed $data
* @return mixed
*/
public function afterRetrieve($data){ }
}
}