Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431745
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
;
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, May 16, 21:02 (1 d, 20 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
39/e7/87d0053ff9c4322e384cc6d349c2
Default Alt Text
PersistentCacheEntry.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment