Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isDuplicateKeyException example
public
function
save
(
Key
$key
)
{
$key
->
reduceLifetime
(
$this
->initialTtl
)
;
try
{
$this
->
upsert
(
$key
,
$this
->initialTtl
)
;
}
catch
(
WriteException
$e
)
{
if
(
$this
->
isDuplicateKeyException
(
$e
)
)
{
throw
new
LockConflictedException
(
'Lock was acquired by someone else.', 0,
$e
)
;
}
throw
new
LockAcquiringException
(
'Failed to acquire lock.', 0,
$e
)
;
}
if
(
$this
->options
[
'gcProbability'
]
> 0.0
&&
(
1.0 ===
$this
->options
[
'gcProbability'
]
||
(
random_int
(
0, \PHP_INT_MAX
)
/ \PHP_INT_MAX
)
<=
$this
->options
[
'gcProbability'
]
)
)
{
$this
->
createTtlIndex
(
)
;
}
$this
->
checkNotExpired
(
$key
)
;
}