sed -i '$a echo - /etc/cache>>$BUFFER' myfile.txt
The $ says the last line and a is append the -i option writes the file in place.
If you want the match anywhere you can address it with a regex / / like this just make sure to escape the / like / since sed expects the regex to be encapsulated in / /
sed -i '/echo + \/etc>>$BUFFER/a echo - /etc/cache>>$BUFFER' myfile.txt
Since the (copy & paste) of the above statement omits a space prior to the first + sign (likely due to a BUG in the software that runs the posts to this website) - here is version that should work when copied ):
sed -i '/echo \ + \/etc>>$BUFFER/a echo - /etc/cache>>$BUFFER' myfile.txt
or if you want to avoid escaping the single front slash in the future (not really useful in this case since its only one but if you had a lot of front slashes - again weird escaped space is only due to a BUG in the software of this website (or my browser firefox) if you type it on the command line you can put the spacing double yourself as it appears in the askers question) :
sed -i '\@echo \ + /etc>>$BUFFER@a echo - /etc/cache>>$BUFFER' myfile.txt