관리-도구
편집 파일: cache.cpython-37.pyc
B �C]8 � @ sX d dl mZ d dl mZ e�d�ZejZeddd� G dd� de�ZG d d � d e�Z dS )� )�compat)�utilz mako.cacheZbeakerzmako.ext.beaker_cacheZBeakerCacheImplc @ sx e Zd ZdZdZdZdZdd� Zdd� Zdd� Z d d � Z dd� ZeZd d� Z dd� Zdd� Zdd� Zdd� Zdd� ZdS )�Cachea� Represents a data content cache made available to the module space of a specific :class:`.Template` object. .. versionadded:: 0.6 :class:`.Cache` by itself is mostly a container for a :class:`.CacheImpl` object, which implements a fixed API to provide caching services; specific subclasses exist to implement different caching strategies. Mako includes a backend that works with the Beaker caching system. Beaker itself then supports a number of backends (i.e. file, memory, memcached, etc.) The construction of a :class:`.Cache` is part of the mechanics of a :class:`.Template`, and programmatic access to this cache is typically via the :attr:`.Template.cache` attribute. Nc G sH t |tj�r|rd S || _|jj| _|jj| _i | _ | � | jj�| _d S )N) � isinstancer �string_types�template�module�__name__�idZ_modified_time� starttime�_def_regions� _load_implZ cache_impl�impl)�selfr �args� r �;/opt/alt/python37/lib/python3.7/site-packages/mako/cache.py�__init__B s zCache.__init__c C s t �|�| �S )N)�_cache_plugins�load)r �namer r r r M s zCache._load_implc K s | j ||df|�S )zcRetrieve a value from the cache, using the given creation function to generate a new value.N)�_ctx_get_or_create)r �key�creation_function�kwr r r � get_or_createP s zCache.get_or_createc K s( | j js|� S | jj||f| �||��S )zcRetrieve a value from the cache, using the given creation function to generate a new value.)r Z cache_enabledr r � _get_cache_kw)r r r �contextr r r r r V s zCache._ctx_get_or_createc K s | j j||f| �|d�� dS )z�Place a value in the cache. :param key: the value's key. :param value: the value. :param \**kw: cache configuration arguments. N)r �setr )r r �valuer r r r r a s z Cache.setc K s | j j|f| �|d��S )aF Retrieve a value from the cache. :param key: the value's key. :param \**kw: cache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend. N)r �getr )r r r r r r r s s z Cache.getc K s | j j|f| �|d�� dS )aF Invalidate a value in the cache. :param key: the value's key. :param \**kw: cache configuration arguments. The backend is configured using these arguments upon first request. Subsequent requests that use the same series of configuration values will use that same backend. N)r � invalidater )r r r r r r r! s zCache.invalidatec C s | j ddd� dS )zWInvalidate the cached content of the "body" method for this template. Zrender_body)�__M_defnameN)r! )r r r r �invalidate_body� s zCache.invalidate_bodyc C s | j d| d| d� dS )z`Invalidate the cached content of a particular ``<%def>`` within this template. z render_%s)r"