Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sometimes it is necessary to keep global information. These functions provide very simple key value store functionality.There are two kinds of stores named and unnamed. There are no restrictions, who can access the content of the stores if the keys are known. The user is responsible for clearing the store, else an OutOfMemory could occur.

kvwrite(String key, Object value)

Stores a value under the given key. If there is already a value, this value is overwritten.

kvread(String key)

Returns the value that is stored with this key. If no value is stored, null will be returned,

kvremove(String key)

Same as kvread but removes the value from the storeA more advanced version can be found in the Key Value Store Feature.

kvwrite(String

...

key, Object value)

Stores a value in the given store under the given key. If there is already a value, this value is overwritten.

kvread(String

...

key)

Returns the value that is stored with this key in this store. If no value is stored, null will be returned,

kvremove(String

...

key)

Same as kvread but removes the value from the store.If the named store is empty, the store will be removed. 


Code Block
#PARSER PQL
#RUNQUERY
timer = TIMER({
            period = 1000,
            source = 'timersource'
          }
        )

Map1 = MAP({
            expressions = [
                    'kvwrite("10","1",1)',
                    ['kvread("10","1")','out'],
                    'kvremove("10","1")',
                    ['kvread("10","1")','ShouldBeNull']
            ]
          },
          timer
)
Map2 = MAP({
            expressions = [
                    'kvwrite("1",1)',
                    ['kvread("1")','out'],
                    'kvremove("1")',
                    ['kvread("1")','ShouldBeNull']
            ]
          },
          timer
)