How to create persistent variables in AppDaemon?

Hi,

I would like to make a variable persistent. AppDaemon has the ability but it is unclear (to me) how to use it. I have add a namespace to appdaemon.yaml and restarted, according to this.

But now how do I use it?
self.set_namespace("bplus_ns")
self.somevar = 'value to persist'
self.set_namespace("default")
does not work… Does somebody have a working example?

I have figured it out (thanks @aimc !). This is my appdaemon.yaml entry:

appdaemon:
  latitude: !secret latitude
  longitude: !secret longitude
  elevation: !secret elevation
  time_zone: !secret time_zone
  plugins:
    HASS:
      type: hass
  namespaces:
    bplus_ns:
      writeback: safe

And this is a sample app:

class HelloWorld(hass.Hass):

    def initialize(self):
        self.log("Hello from AppDaemon")
        # set namespace
        self.set_namespace("bplus_ns")
        try:
            # try to retrieve the variable from the namespace
            self.test = self.get_state("text.test")
            self.log("retrieved:")
            self.log(self.test)
        except:
            self.test = int(1)
            self.set_state("text.test", state=self.test)
            self.log("created:")
            self.log(self.test)
        
        # multiply the saved value
        state = self.test*2
        # Save to namespace
        self.set_state("text.test", state=state)
        self.log(self.test)

Everytime the app starts, the value is increased.