How to use the cachetools.cachedmethod function in cachetools

To help you get started, we’ve selected a few cachetools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nocproject / noc / core / migration / loader.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_migration_cache"))
    def get_migration(cls, name):
        """
        Get migration instance
        :param name: Migration name
        :return:
        """
        app, mname = name.split(".")
        # @todo: Consider custom
        m = __import__("noc.%s.migrations.%s" % (app, mname), {}, {}, "Migration")
        assert m
        return m.Migration()
github nocproject / noc / sa / models / administrativedomain.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_bi_id_cache"), lock=lambda _: id_lock)
    def get_by_bi_id(cls, id):
        ad = AdministrativeDomain.objects.filter(bi_id=id)[:1]
        if ad:
            return ad[0]
        return None
github nocproject / noc / fm / models / eventclass.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
    def get_by_id(cls, id):
        return EventClass.objects.filter(id=id).first()
github nocproject / noc / aaa / models / group.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
    def get_by_id(cls, id):
        return Group.objects.filter(id=id).first()
github nocproject / noc / gis / models / layer.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
    def get_by_id(cls, id):
        try:
            return Layer.objects.get(id=id)
        except Layer.DoesNotExist:
            return None
github nocproject / noc / ip / models / addressprofile.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_name_cache"), lock=lambda _: id_lock)
    def get_by_name(cls, name):
        return AddressProfile.objects.filter(name=name).first()
github nocproject / noc / core / collection / base.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_state_cache"), lock=lambda _: state_lock)
    def get_builtins(cls, name):
        """
        Returns set of UUIDs for collection
        :param name:
        :return:
        """
        return set(Collection(name).get_state())
github nocproject / noc / peer / models / asprofile.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
    def get_by_id(cls, id):
        return ASProfile.objects.filter(id=id).first()
github nocproject / noc / services / discovery / jobs / periodic / interfacestatus.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_ips_cache"), lock=lambda _: ips_lock)
    def get_profiles(cls, x):
        return list(InterfaceProfile.objects.filter(status_discovery=True))
github nocproject / noc / inv / models / platform.py View on Github external
    @cachetools.cachedmethod(operator.attrgetter("_bi_id_cache"), lock=lambda _: id_lock)
    def get_by_bi_id(cls, id):
        return Platform.objects.filter(bi_id=id).first()