UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'P7B7C/9UpQljS24XYEN2JpyPKwA1YYV3h7R9b4x5oWo='
WHERE
key_id = '309f407e534db5c76c99367031d882a2417899fb11766bf4ef52c7c72d7371ec'
AND (
token = 'P7B7C/9UpQljS24XYEN2JpyPKwA1YYV3h7R9b4x5oWo='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)