Use specific RTD link to SDL documentation
[ric-plt/sdlpy.git] / ricsdl-package / examples / sync.py
index c75dfb6..6ea9ef9 100644 (file)
@@ -73,6 +73,16 @@ def _try_func_return(func):
 # Creates SDL instance. The call creates connection to the SDL database backend.
 mysdl = _try_func_return(SyncStorage)
 
+# Creates SDL instance what utilizes a fake database backend. Fake database is meant to
+# be used only at development phase of SDL clients. It does not provide more advanced
+# database services.
+# mysdl = _try_func_return(lambda: SyncStorage(fake_db_backend='dict'))
+
+# Checks if SDL is operational. Note that it is not necessary to call `is_active()` after each
+# SDL instance creation. Below example is here just to show how to call it spontaneously
+# when SDL healthiness is needed to check.
+is_active = mysdl.is_active()
+assert is_active is True
 
 # Sets a value 'my_value' for a key 'my_key' under given namespace. Note that value
 # type must be bytes and multiple key values can be set in one set function call.
@@ -132,13 +142,14 @@ assert my_ret_dict == {}
 
 # Finds keys under given namespace that are matching to given key prefix 'my_k'.
 _try_func_return(lambda: mysdl.set(MY_NS, {'my_key': b'my_value'}))
-ret_keys = _try_func_return(lambda: mysdl.find_keys(MY_NS, ''))
+ret_keys = _try_func_return(lambda: mysdl.find_keys(MY_NS, 'my_k*'))
 assert ret_keys == ['my_key']
 
 
-# Finds keys and their values under given namespace that are matching to given key prefix 'my_k'.
+# Finds keys and their values under given namespace that are matching to given key search
+# pattern 'my_k*'.
 # Note that the type of returned value is bytes.
-ret_key_values = _try_func_return(lambda: mysdl.find_and_get(MY_NS, '', atomic=True))
+ret_key_values = _try_func_return(lambda: mysdl.find_and_get(MY_NS, 'my_k*'))
 assert ret_key_values == {'my_key': b'my_value'}
 
 _try_func_return(lambda: mysdl.remove_all(MY_NS))