Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
WheelCache Class Reference
Inheritance diagram for WheelCache:
Collaboration diagram for WheelCache:

Public Member Functions

None __init__ (self, str cache_dir)
 
str get_path_for_link (self, Link link)
 
str get_ephem_path_for_link (self, Link link)
 
Link get (self, Link link, Optional[str] package_name, List[Tag] supported_tags)
 
Optional[CacheEntryget_cache_entry (self, Link link, Optional[str] package_name, List[Tag] supported_tags)
 

Static Public Member Functions

None record_download_origin (str cache_dir, DirectUrl download_info)
 

Protected Attributes

 _wheel_cache
 
 _ephem_cache
 

Additional Inherited Members

- Data Fields inherited from Cache
 cache_dir
 
- Protected Member Functions inherited from Cache
List[str] _get_cache_path_parts (self, Link link)
 
List[Any] _get_candidates (self, Link link, str canonical_package_name)
 

Detailed Description

Wraps EphemWheelCache and SimpleWheelCache into a single Cache

This Cache allows for gracefully degradation, using the ephem wheel cache
when a certain link is not found in the simple wheel cache first.

Definition at line 210 of file cache.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
str  cache_dir 
)

Reimplemented from Cache.

Definition at line 217 of file cache.py.

217 def __init__(self, cache_dir: str) -> None:
218 super().__init__(cache_dir)
219 self._wheel_cache = SimpleWheelCache(cache_dir)
220 self._ephem_cache = EphemWheelCache()
221
for i

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ get()

Link get (   self,
Link  link,
Optional[str]  package_name,
List[Tag supported_tags 
)
Returns a link to a cached item if it exists, otherwise returns the
passed link.

Reimplemented from Cache.

Definition at line 228 of file cache.py.

233 ) -> Link:
234 cache_entry = self.get_cache_entry(link, package_name, supported_tags)
235 if cache_entry is None:
236 return link
237 return cache_entry.link
238

Referenced by LegacyMetadata.__getitem__(), Layout.__getitem__(), LegacyMetadata.check(), ThemeStack.push_theme(), and LegacyMetadata.write_file().

Here is the caller graph for this function:

◆ get_cache_entry()

Optional[CacheEntry] get_cache_entry (   self,
Link  link,
Optional[str]  package_name,
List[Tag supported_tags 
)
Returns a CacheEntry with a link to a cached item if it exists or
None. The cache entry indicates if the item was found in the persistent
or ephemeral cache.

Definition at line 239 of file cache.py.

244 ) -> Optional[CacheEntry]:
245 """Returns a CacheEntry with a link to a cached item if it exists or
246 None. The cache entry indicates if the item was found in the persistent
247 or ephemeral cache.
248 """
249 retval = self._wheel_cache.get(
250 link=link,
251 package_name=package_name,
252 supported_tags=supported_tags,
253 )
254 if retval is not link:
255 return CacheEntry(retval, persistent=True)
256
257 retval = self._ephem_cache.get(
258 link=link,
259 package_name=package_name,
260 supported_tags=supported_tags,
261 )
262 if retval is not link:
263 return CacheEntry(retval, persistent=False)
264
265 return None
266

◆ get_ephem_path_for_link()

str get_ephem_path_for_link (   self,
Link  link 
)

Definition at line 225 of file cache.py.

225 def get_ephem_path_for_link(self, link: Link) -> str:
226 return self._ephem_cache.get_path_for_link(link)
227

◆ get_path_for_link()

str get_path_for_link (   self,
Link  link 
)
Return a directory to store cached items in for link.

Reimplemented from Cache.

Definition at line 222 of file cache.py.

222 def get_path_for_link(self, link: Link) -> str:
223 return self._wheel_cache.get_path_for_link(link)
224

◆ record_download_origin()

None record_download_origin ( str  cache_dir,
DirectUrl  download_info 
)
static

Definition at line 268 of file cache.py.

268 def record_download_origin(cache_dir: str, download_info: DirectUrl) -> None:
269 origin_path = Path(cache_dir) / ORIGIN_JSON_NAME
271 try:
272 origin = DirectUrl.from_json(origin_path.read_text(encoding="utf-8"))
273 except Exception as e:
275 "Could not read origin file %s in cache entry (%s). "
276 "Will attempt to overwrite it.",
277 origin_path,
278 e,
279 )
280 else:
281 # TODO: use DirectUrl.equivalent when
282 # https://github.com/pypa/pip/pull/10564 is merged.
285 "Origin URL %s in cache entry %s does not match download URL "
286 "%s. This is likely a pip bug or a cache corruption issue. "
287 "Will overwrite it with the new value.",
289 cache_dir,
291 )

Field Documentation

◆ _ephem_cache

_ephem_cache
protected

Definition at line 220 of file cache.py.

◆ _wheel_cache

_wheel_cache
protected

Definition at line 219 of file cache.py.

Referenced by Factory.get_wheel_cache_entry().


The documentation for this class was generated from the following file: