2525 "Cache" ,
2626 "MemcacheCache" ,
2727 "MemoryCache" ,
28- "RequestCache" ,
2928 "get_memcache" ,
3029 "memcache_memoize" ,
3130 "memoize" ,
@@ -267,7 +266,11 @@ def delete(self, key):
267266
268267
269268class MemoryCache (Cache ):
270- """Cache implementation in memory."""
269+ """Cache implementation in memory.
270+
271+ Note: expires is ignored. Values stay until deleted or cleared.
272+ Use MemcacheCache if you need expiration.
273+ """
271274
272275 def __init__ (self ):
273276 self .d = {}
@@ -354,32 +357,8 @@ def delete(self, key):
354357 return value
355358
356359
357- class RequestCache (Cache ):
358- """Request-Local cache.
359-
360- The values are cached only in the context of the current request.
361- """
362-
363- @property
364- def d (self ):
365- return web .ctx .setdefault ("request-local-cache" , {})
366-
367- def get (self , key ):
368- return self .d .get (key )
369-
370- def set (self , key , value , expires = 0 ):
371- self .d [key ] = value
372-
373- def add (self , key , value , expires = 0 ):
374- return self .d .setdefault (key , value ) is value
375-
376- def delete (self , key ):
377- return self .d .pop (key , None ) is not None
378-
379-
380360memory_cache = MemoryCache ()
381361memcache_cache = MemcacheCache ()
382- request_cache = RequestCache ()
383362
384363
385364def get_memcache ():
@@ -390,8 +369,6 @@ def _get_cache(engine):
390369 d = {
391370 "memory" : memory_cache ,
392371 "memcache" : memcache_cache ,
393- "memcache+memory" : memcache_cache ,
394- "request" : request_cache ,
395372 }
396373 return d .get (engine )
397374
@@ -411,7 +388,6 @@ def some_func(args):
411388 Engine to store the results. Available options are:
412389 * memory: stores the result in memory.
413390 * memcache: stores the result in memcached.
414- * request: stores the result only in the context of the current request.
415391
416392 * key:
417393 key to be used in the cache. If this is a string, arguments are append
@@ -453,7 +429,7 @@ def get_page(key):
453429
454430 def __init__ (
455431 self ,
456- engine : Literal ["memory" , "memcache" , "request" ],
432+ engine : Literal ["memory" , "memcache" ],
457433 key : str | Callable [..., str | tuple ],
458434 expires : int = 0 ,
459435 background : bool = False ,
0 commit comments