UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Y6Vb2IaKav8tYgb7yyabRbm88jeN8wVkouMm08XqRZU='
WHERE
key_id = 'c9584041084f8f516567b701a834eac21ec5643be34c996a22c9894787eb7dfc'
AND (
token = 'Y6Vb2IaKav8tYgb7yyabRbm88jeN8wVkouMm08XqRZU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)