aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/simplepie/simplepie/library/SimplePie/Cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/simplepie/simplepie/library/SimplePie/Cache.php')
-rw-r--r--vendor/simplepie/simplepie/library/SimplePie/Cache.php99
1 files changed, 90 insertions, 9 deletions
diff --git a/vendor/simplepie/simplepie/library/SimplePie/Cache.php b/vendor/simplepie/simplepie/library/SimplePie/Cache.php
index 034af74e2..88d811660 100644
--- a/vendor/simplepie/simplepie/library/SimplePie/Cache.php
+++ b/vendor/simplepie/simplepie/library/SimplePie/Cache.php
@@ -5,7 +5,7 @@
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
- * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
+ * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@@ -41,15 +41,96 @@
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
-use SimplePie\Cache;
+/**
+ * Used to create cache objects
+ *
+ * This class can be overloaded with {@see SimplePie::set_cache_class()},
+ * although the preferred way is to create your own handler
+ * via {@see register()}
+ *
+ * @package SimplePie
+ * @subpackage Caching
+ */
+class SimplePie_Cache
+{
+ /**
+ * Cache handler classes
+ *
+ * These receive 3 parameters to their constructor, as documented in
+ * {@see register()}
+ * @var array
+ */
+ protected static $handlers = array(
+ 'mysql' => 'SimplePie_Cache_MySQL',
+ 'memcache' => 'SimplePie_Cache_Memcache',
+ 'memcached' => 'SimplePie_Cache_Memcached',
+ 'redis' => 'SimplePie_Cache_Redis'
+ );
-class_exists('SimplePie\Cache');
+ /**
+ * Don't call the constructor. Please.
+ */
+ private function __construct() { }
-// @trigger_error(sprintf('Using the "SimplePie_Cache" class is deprecated since SimplePie 1.7, use "SimplePie\Cache" instead.'), \E_USER_DEPRECATED);
+ /**
+ * Create a new SimplePie_Cache object
+ *
+ * @param string $location URL location (scheme is used to determine handler)
+ * @param string $filename Unique identifier for cache object
+ * @param string $extension 'spi' or 'spc'
+ * @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
+ */
+ public static function get_handler($location, $filename, $extension)
+ {
+ $type = explode(':', $location, 2);
+ $type = $type[0];
+ if (!empty(self::$handlers[$type]))
+ {
+ $class = self::$handlers[$type];
+ return new $class($location, $filename, $extension);
+ }
-if (\false) {
- /** @deprecated since SimplePie 1.7, use "SimplePie\Cache" instead */
- class SimplePie_Cache extends Cache
- {
- }
+ return new SimplePie_Cache_File($location, $filename, $extension);
+ }
+
+ /**
+ * Create a new SimplePie_Cache object
+ *
+ * @deprecated Use {@see get_handler} instead
+ */
+ public function create($location, $filename, $extension)
+ {
+ trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
+ return self::get_handler($location, $filename, $extension);
+ }
+
+ /**
+ * Register a handler
+ *
+ * @param string $type DSN type to register for
+ * @param string $class Name of handler class. Must implement SimplePie_Cache_Base
+ */
+ public static function register($type, $class)
+ {
+ self::$handlers[$type] = $class;
+ }
+
+ /**
+ * Parse a URL into an array
+ *
+ * @param string $url
+ * @return array
+ */
+ public static function parse_URL($url)
+ {
+ $params = parse_url($url);
+ $params['extras'] = array();
+ if (isset($params['query']))
+ {
+ parse_str($params['query'], $params['extras']);
+ }
+ return $params;
+ }
}
+
+class_alias('SimplePie_Cache', 'SimplePie\Cache', false);