def storage()

in python/showcase/showcase/__main__.py [0:0]


def storage(context, message):
    # each function invocation gets access to storage that is scoped to the current function
    # instance's address, i.e. (function typename, instance id). For example, if (UserFn, "Gordon")
    # was invoked, the values you get access to belongs specifically to user Gordon.
    storage = context.storage

    # each value spec defined above, will appear as a property on the storage.
    print(storage.an_int)
    storage.an_int = 42

    # a value can be None if it has expired, or never set before.
    if storage.an_expiring_str:
        print(storage.an_expiring_str)
    else:
        print("Oh no, the str has expiried (or wasn't set before)")

    # a value can also be deleted
    storage.greet_json = {"name": "Anton"}
    del storage.greet_json