UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'fq9ahmZVT1fDdYBiQbHPHqt8Wne4JLWJT45AK2ff6rs='
WHERE
key_id = '9e2f2e5154532ad4c6877c557c960d25a79c4e54d1069b464a594664c42d2bfb'
AND (
token = 'fq9ahmZVT1fDdYBiQbHPHqt8Wne4JLWJT45AK2ff6rs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)