UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'K6AqOMOx924iI/fSaGXlk+dFy8KmwTeunhJkm+C2jes='
WHERE
key_id = '83f4e231eb5c33a855ce2fcc7e40c4fd1e157b9c8e86a0e4957d1075a6896957'
AND (
token = 'K6AqOMOx924iI/fSaGXlk+dFy8KmwTeunhJkm+C2jes='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)