Module QFlow.helpers.stores.sessionStorage

Classes

class SessionStorage
Expand source code
@dataclass
class SessionStorage:
    """
    A class that simulates session storage in memory.

    This class provides methods for storing, retrieving, and removing key-value pairs
    in memory, which mimics a session storage mechanism. The storage is global across
    all instances of the application.

    Attributes:
        storage (dict): A dictionary to store session data.
    """
    
    storage = {}

    def getItem(self, item: str):
        """
        Retrieves an item from the session storage.

        Args:
            item (str): The key of the item to retrieve.

        Returns:
            The value associated with the provided key, or None if the key does not exist.
        """
        return self.storage.get(item)

    def setItem(self, name: str, value) -> None:
        """
        Adds or updates an item in the session storage.

        Args:
            name (str): The key to store the item under.
            value: The value to associate with the given key.
        """
        self.storage[name] = value
    
    def removeItem(self, item: str) -> None:
        """
        Removes an item from the session storage.

        Args:
            item (str): The key of the item to remove.
        """
        self.storage.pop(item, None)

A class that simulates session storage in memory.

This class provides methods for storing, retrieving, and removing key-value pairs in memory, which mimics a session storage mechanism. The storage is global across all instances of the application.

Attributes
-----=
storage : dict
A dictionary to store session data.

Class variables

var storage

The type of the None singleton.

Methods

def getItem(self, item: str)
Expand source code
def getItem(self, item: str):
    """
    Retrieves an item from the session storage.

    Args:
        item (str): The key of the item to retrieve.

    Returns:
        The value associated with the provided key, or None if the key does not exist.
    """
    return self.storage.get(item)

Retrieves an item from the session storage.

Args
-----=
item : str
The key of the item to retrieve.

Returns -----= The value associated with the provided key, or None if the key does not exist.

def removeItem(self, item: str) ‑> None
Expand source code
def removeItem(self, item: str) -> None:
    """
    Removes an item from the session storage.

    Args:
        item (str): The key of the item to remove.
    """
    self.storage.pop(item, None)

Removes an item from the session storage.

Args
-----=
item : str
The key of the item to remove.
def setItem(self, name: str, value) ‑> None
Expand source code
def setItem(self, name: str, value) -> None:
    """
    Adds or updates an item in the session storage.

    Args:
        name (str): The key to store the item under.
        value: The value to associate with the given key.
    """
    self.storage[name] = value

Adds or updates an item in the session storage.

Args
-----=
name : str
The key to store the item under.
value
The value to associate with the given key.