UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'xI8qNuRMd81AQS2TrMxGNoQ97g8R+0YUAaTxz9MNev4='
WHERE
key_id = 'd590c2062c7179c5b12fa52e94b1781b5447e3c8a509c5067fb84b86cb10461b'
AND (
token = 'xI8qNuRMd81AQS2TrMxGNoQ97g8R+0YUAaTxz9MNev4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)