Module ro_py.utilities.cache

Expand source code
import enum


class CacheType(enum.Enum):
    Users = "users"
    Groups = "groups"
    Games = "games"
    Assets = "assets"
    Badges = "badges"


class Cache:
    def __init__(self):
        self.cache = {
            "users": {},
            "groups": {},
            "games": {},
            "assets": {},
            "badges": {}
        }

    def get(self, cache_type: CacheType, item_id: str):
        if item_id in self.cache[cache_type.value]:
            return self.cache[cache_type.value][item_id]
        else:
            return False

    def set(self, cache_type: CacheType, item_id: str, item_obj):
        self.cache[cache_type.value][item_id] = item_obj

Classes

class Cache
Expand source code
class Cache:
    def __init__(self):
        self.cache = {
            "users": {},
            "groups": {},
            "games": {},
            "assets": {},
            "badges": {}
        }

    def get(self, cache_type: CacheType, item_id: str):
        if item_id in self.cache[cache_type.value]:
            return self.cache[cache_type.value][item_id]
        else:
            return False

    def set(self, cache_type: CacheType, item_id: str, item_obj):
        self.cache[cache_type.value][item_id] = item_obj

Methods

def get(self, cache_type: CacheType, item_id: str)
Expand source code
def get(self, cache_type: CacheType, item_id: str):
    if item_id in self.cache[cache_type.value]:
        return self.cache[cache_type.value][item_id]
    else:
        return False
def set(self, cache_type: CacheType, item_id: str, item_obj)
Expand source code
def set(self, cache_type: CacheType, item_id: str, item_obj):
    self.cache[cache_type.value][item_id] = item_obj
class CacheType (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
class CacheType(enum.Enum):
    Users = "users"
    Groups = "groups"
    Games = "games"
    Assets = "assets"
    Badges = "badges"

Ancestors

  • enum.Enum

Class variables

var Assets
var Badges
var Games
var Groups
var Users