Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7402330
PersistentCacheEntry.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PersistentCacheEntry.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\Cache
;
use
DateTime
;
use
InvalidArgumentException
;
/**
* Represents a single result from the persistent cache
* @author Abijeet Patro
* @license GPL-2.0-or-later
* @since 2020.12
*/
class
PersistentCacheEntry
{
private
const
MAX_KEY_LENGTH
=
255
;
private
const
MAX_TAG_LENGTH
=
255
;
private
string
$key
;
/** @var mixed */
private
$value
;
private
?
int
$exptime
;
private
?
string
$tag
;
/**
* @param string $key
* @param mixed|null $value
* @param int|null $exptime
* @param string|null $tag
*/
public
function
__construct
(
string
$key
,
$value
=
null
,
?
int
$exptime
=
null
,
?
string
$tag
=
null
)
{
if
(
strlen
(
$key
)
>
self
::
MAX_KEY_LENGTH
)
{
throw
new
InvalidArgumentException
(
"The length of key: $key is greater than allowed "
.
self
::
MAX_KEY_LENGTH
);
}
if
(
$tag
&&
strlen
(
$tag
)
>
self
::
MAX_TAG_LENGTH
)
{
throw
new
InvalidArgumentException
(
"The length of tag: $tag is greater than allowed "
.
self
::
MAX_TAG_LENGTH
);
}
$this
->
key
=
$key
;
$this
->
value
=
$value
;
$this
->
exptime
=
$exptime
;
$this
->
tag
=
$tag
;
}
public
function
key
():
string
{
return
$this
->
key
;
}
/** @return mixed */
public
function
value
()
{
return
$this
->
value
;
}
public
function
exptime
():
?
int
{
return
$this
->
exptime
;
}
public
function
tag
():
?
string
{
return
$this
->
tag
;
}
public
function
hasExpired
():
bool
{
if
(
$this
->
exptime
)
{
return
$this
->
exptime
<
(
new
DateTime
()
)->
getTimestamp
();
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 17:59 (17 h, 57 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
99/5b/c7e31d062be4453074c2bf9f02db
Default Alt Text
PersistentCacheEntry.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment