UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'a6L8JcqguAHCeN4adZTqxYHirpfT1x0hUJ7xWkd1wms='
WHERE
key_id = '8a661678325869b1a6fa011c42603794cf953ded429e85ddf04e2f28fced3b4a'
AND (
token = 'a6L8JcqguAHCeN4adZTqxYHirpfT1x0hUJ7xWkd1wms='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)