Subversion-Projekte lars-tiefland.ci

Revision

Revision 2049 | Revision 2242 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2049 Revision 2107
Zeile 78... Zeile 78...
78
	public function get($id)
78
	public function get($id)
79
	{
79
	{
80
		$success = FALSE;
80
		$success = FALSE;
81
		$data = apc_fetch($id, $success);
81
		$data = apc_fetch($id, $success);
Zeile 82... Zeile 82...
82
 
82
 
83
		if ($success === TRUE)
-
 
84
		{
-
 
85
			return is_array($data)
-
 
86
				? unserialize($data[0])
-
 
87
				: $data;
-
 
88
		}
-
 
89
 
-
 
90
		return FALSE;
83
		return ($success === TRUE) ? $data : FALSE;
Zeile 91... Zeile 84...
91
	}
84
	}
Zeile 92... Zeile 85...
92
 
85
 
93
	// ------------------------------------------------------------------------
86
	// ------------------------------------------------------------------------
94
 
87
 
95
	/**
88
	/**
96
	 * Cache Save
89
	 * Cache Save
97
	 *
90
	 *
98
	 * @param	string	$id	Cache ID
91
	 * @param	string	$id	Cache ID
99
	 * @param	mixed	$data	Data to store
92
	 * @param	mixed	$data	Data to store
100
	 * @param	int	$ttl	Length of time (in seconds) to cache the data
93
	 * @param	int	$ttl	Length of time (in seconds) to cache the data
101
	 * @param	bool	$raw	Whether to store the raw value
94
	 * @param	bool	$raw	Whether to store the raw value (unused)
102
	 * @return	bool	TRUE on success, FALSE on failure
95
	 * @return	bool	TRUE on success, FALSE on failure
103
	 */
-
 
104
	public function save($id, $data, $ttl = 60, $raw = FALSE)
-
 
105
	{
96
	 */
106
		$ttl = (int) $ttl;
-
 
107
 
-
 
108
		return apc_store(
-
 
109
			$id,
-
 
110
			($raw === TRUE ? $data : array(serialize($data), time(), $ttl)),
97
	public function save($id, $data, $ttl = 60, $raw = FALSE)
Zeile 111... Zeile 98...
111
			$ttl
98
	{
Zeile 112... Zeile 99...
112
		);
99
		return apc_store($id, $data, (int) $ttl);
Zeile 186... Zeile 173...
186
	 * @param	mixed	key to get cache metadata on
173
	 * @param	mixed	key to get cache metadata on
187
	 * @return	mixed	array on success/false on failure
174
	 * @return	mixed	array on success/false on failure
188
	 */
175
	 */
189
	public function get_metadata($id)
176
	public function get_metadata($id)
190
	{
177
	{
191
		$success = FALSE;
-
 
192
		$stored = apc_fetch($id, $success);
178
		$cache_info = apc_cache_info('user', FALSE);
193
 
-
 
194
		if ($success === FALSE OR count($stored) !== 3)
179
		if (empty($cache_info) OR empty($cache_info['cache_list']))
195
		{
180
		{
196
			return FALSE;
181
			return FALSE;
197
		}
182
		}
Zeile -... Zeile 183...
-
 
183
 
-
 
184
		foreach ($cache_info['cache_list'] as &$entry)
198
 
185
		{
-
 
186
			if ($entry['info'] !== $id)
-
 
187
			{
-
 
188
				continue;
-
 
189
			}
-
 
190
 
-
 
191
			$success  = FALSE;
-
 
192
			$metadata = array(
-
 
193
				'expire' => ($entry['ttl'] ? $entry['mtime'] + $entry['ttl'] : 0),
-
 
194
				'mtime'  => $entry['ttl'],
-
 
195
				'data'   => apc_fetch($id, $success)
Zeile 199... Zeile -...
199
		list($data, $time, $ttl) = $stored;
-
 
200
 
196
			);
201
		return array(
-
 
202
			'expire'	=> $time + $ttl,
-
 
203
			'mtime'		=> $time,
197
 
-
 
198
			return ($success === TRUE) ? $metadata : FALSE;
-
 
199
		}
204
			'data'		=> unserialize($data)
200
 
Zeile 205... Zeile 201...
205
		);
201
		return FALSE;
Zeile 206... Zeile 202...
206
	}
202
	}