| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/././mahyarcake/public_html/wp-content/plugins/polylang/include/ |
Upload File : |
<?php
/**
* @package Polylang
*/
/**
* An extremely simple non persistent cache system.
*
* @since 1.7
*
* @template TCacheData
*/
class PLL_Cache {
/**
* Current site id.
*
* @var int
*/
protected $blog_id;
/**
* The cache container.
*
* @var array
*
* @phpstan-var array<int, array<non-empty-string, TCacheData>>
*/
protected $cache = array();
/**
* Constructor.
*
* @since 1.7
*/
public function __construct() {
$this->blog_id = get_current_blog_id();
add_action( 'switch_blog', array( $this, 'switch_blog' ) );
}
/**
* Called when switching blog.
*
* @since 1.7
*
* @param int $new_blog_id New blog ID.
* @return void
*/
public function switch_blog( $new_blog_id ) {
$this->blog_id = $new_blog_id;
}
/**
* Adds a value in cache.
*
* @since 1.7
* @since 3.6 Returns the cached value.
*
* @param string $key Cache key.
* @param mixed $data The value to add to the cache.
* @return mixed
*
* @phpstan-param non-empty-string $key
* @phpstan-param TCacheData $data
* @phpstan-return TCacheData
*/
public function set( $key, $data ) {
$this->cache[ $this->blog_id ][ $key ] = $data;
return $data;
}
/**
* Returns value from cache.
*
* @since 1.7
*
* @param string $key Cache key.
* @return mixed
*
* @phpstan-param non-empty-string $key
* @phpstan-return TCacheData|false
*/
public function get( $key ) {
return isset( $this->cache[ $this->blog_id ][ $key ] ) ? $this->cache[ $this->blog_id ][ $key ] : false;
}
/**
* Cleans the cache (for this blog only).
*
* @since 1.7
*
* @param string $key Optional. Cache key. An empty string to clean the whole cache for the current blog.
* Default is an empty string.
* @return void
*/
public function clean( $key = '' ) {
if ( '' === $key ) {
unset( $this->cache[ $this->blog_id ] );
} else {
unset( $this->cache[ $this->blog_id ][ $key ] );
}
}
/**
* Generates and returns a "unique" cache key, depending on `$data` and prefixed by `$prefix`.
*
* @since 3.6
*
* @param string $prefix String to prefix the cache key.
* @param string|array|object $data Data.
* @return string
*
* @phpstan-param non-empty-string $prefix
* @phpstan-return non-empty-string
*/
public function get_unique_key( string $prefix, $data ): string {
/** @var scalar */
$serialized = maybe_serialize( $data );
return $prefix . md5( (string) $serialized );
}
}