Exemplo n.º 1
0
    def cache_for(self, time=None, type=None):
        """Set time and type for cache

        Keyword Arguments:
            time {string} -- Time to cache template for (default: {None})
            type {string} -- Type of the cache. (default: {None})

        Raises:
            RequiredContainerBindingNotFound -- Thrown when the Cache key binding is not found in the container.

        Returns:
            self
        """

        if not self.container.has('Cache'):
            raise RequiredContainerBindingNotFound(
                "The 'Cache' container binding is required to use this method and wasn't found in the container. You may be missing a Service Provider"
            )

        self.cache = True
        self.cache_time = float(time)
        self.cache_type = type
        if self.__is_expired_cache():
            self.__create_cache_template(self.template)
        return self
Exemplo n.º 2
0
    def cache_for(self, time=None, type=None):
        """
        Set time and type for cache
        """

        if not self.container.has('Cache'):
            raise RequiredContainerBindingNotFound(
                "The 'Cache' container binding is required to use this method and wasn't found in the container. You may be missing a Service Provider"
            )

        self.cache = True
        self.cache_time = float(time)
        self.cache_type = type
        if self.__is_expired_cache():
            self.__create_cache_template(self.template)
        return self