Saravanan666/pypi-org huggingface dataset:
Package: cachelper
Useful cache helpers in one package!InstallpipinstallcachelperHelpersIn memory cachememoizeCaching function return values in memory.importcachelper@cachelper.memoize()deffibo(n):ifnin(0,1):return1returnfibo(n-1)+fibo(n-2)fibo(10)Cache with Redis/MemcachedUsing the HelperMixinHelperMixincan be used with any cache client classes that implement the following methods:def get(self, key)def set(self, key, value, timeout=None)def delete(self, key)def get_many(self, keys)def set_many(self, mapping, timeout=None)For example,RedisCachefromwerkzeugis one such class:fromredisimportStrictRedisfromwerkzeug.contrib.cacheimportRedisCacheas_RedisCachefromcachelperimportHelperMixinclassRedisCache(_RedisCache,HelperMixin):'''werkzeug.contrib.cache.RedisCache mixed with HelperMixin'''defget_many(self,keys):returnsuper().get_many(*keys)rds=StrictRedis()cache=RedisCache(rds)This mixin defines these methods:call,map,__call__.
If your class already defines methods of the same name, the mixin methods may not work correctly.cache decoratorAdd cache by decorating a function or method.@cache("key-{user_id}",timeout=300)defget_name(user_id):# Fetch user name from database...The cache key template can also be a function which acts as a key factory:defname_key(user_id):return"key-%s"%user_id@cache(name_key,timeout=300)defget_name(user_id):# Fetch user name from database...Just make sure the key factory function accepts the same parameters as the cached
function and returns the key.cached function callsSometimes we don’t want to cache all calls to a specific function.
So the decorator is not suitable, we may cache the call instead the function in this case:defget_name(user_id):# Fetch user name from database...user_id=42key="key-{user_id}".format(user_id=user_id)cache.call(lambda:get_name(user_id),key,timeout=300)cached multiple callsFor most cache backends, it’s much faster to get or set caches in bulk.defget_name(user_id):# Fetch user name from database...user_ids=[1,2,42,1984]names=cache.map("key-{user_id}",get_name,user_ids,timeout=300)
Package: cache-manager
Cache managerПростой кеш - хранение в файлах:fromcache_manager.pickleimportPickleCachefromdatetimeimporttimedeltacache_manager=PickleCache('./cache')@cache_manager(ttl=timedelta(hours=1))defsome_function():passMemcached:fromcache_manager.memcachedimportMemcachedCachefromdatetimeimporttimedeltacache_manager=MemcachedCache(('10.5.0.11',11211))# в случае соединения по TCP или UDP сокетуcache_manager=MemcachedCache('/usr/run/memcached.sock')# в случае соединия по unix сокету@cache_manager(ttl=timedelta(hours=1))defsome_function():passRedis:fromcache_manager.redisimportRedisCachefromdatetimeimporttimedeltacache_manager=RedisCache(('10.5.0.11',6379),password='somepassword')# в случае соединения по TCP или UDP сокетуcache_manager=RedisCache('/usr/run/redis.sock',password='somepassword')# в случае соединия по unix сокету@cache_manager(ttl=timedelta(hours=1))defsome_function():passEtcd:fromcache_manager.etcdimportEtcdCachefromdatetimeimporttimedeltacache_manager=EtcdCache(('10.5.0.11',2371),scheme='http')@cache_manager(ttl=timedelta(hours=1))defsome_function():pass
Package: cache-map
EXAMPLE CODEc = int(input('Enter the cache memory size : '))
m = input('Enter the memory blocks : ')

print("1. Direct Map\n2. LRU Map")
choice = int(input('Enter the choice : '))

if choice == 1:
	# D I R E C T   M A P
	direct_map = cache_map.CacheMapping(c, m)
	direct_map.directMap()
	direct_map.display()

elif choice == 2:
	# L R U   M A P
	LRU_map = cache_map.CacheMapping(c, m)
	LRU_map.mapLRU()
	LRU_map.display()

else:
	print('Wrong Command')OUTPUT - DIRECT MAPConsider a direct mapped cache with 8 cache blocks (0-7). If the memory block requests are in the order - 3, 5, 2, 8, 0, 6, 3, 9, 16, 20, 17, 25, 18, 30, 24, 2, 63, 5, 82, 17, 24Enter the cache memory size : 8
Enter the memory blocks : 3 5 2 8 0 6 3 9 16 20 17 25 18 30 24 2 63 5 82 17 24
1. Direct Map
2. LRU Map
Enter the choice : 1
Hit :  3
Miss :  18
Memory size :  21
[8, 0, 16, 24]
[9, 17, 25, 17]
[2, 18, 2, 82]
[3]
[20]
[5]
[6, 30]
[63]OUTPUT - LRU MAP7.Consider a fully associative cache with 8 cache blocks (0-7). The memory block requests are in the order - 4, 3, 25, 8, 19, 6, 25, 8, 16, 35, 45, 22, 8, 3, 16, 25, 7Enter the cache memory size : 8
Enter the memory blocks : 4 3 25 8 19 6 25 8 16 35 45 22 8 3 16 25 7
1. Direct Map
2. LRU Map
Enter the choice : 2
Hit :  5
Miss :  12
Memory size :  17
[4, 45]
[3, 22]
[25]
[8]
[19, 3]
[6, 7]
[16]
[35]
Package: cachemonCache
CachemonCache: A Python Package for CachingCachemonCache is a package that provides efficient and fast caching in Python, includingCaching with different eviction algorithms, e.g., FIFO, LRU,S3FIFO,SieveTiered caching using your flashThread-safe caches for multi-threaded applicationsIt uses a similar interface asdictso it can be used as a drop-in replacement for Python dict to save space.News2023-08-01: CachemonCache is under development!InstallationpipinstallCachemonCacheUsage# you can import FIFO, LRU, S3FIFO, SievefromcachemonCacheimportLRUfromcachemonCacheimportS3FIFO# create a cache backed by DRAM, use S3FIFO eviction if you care about hit ratiocache=LRU(size=10)# or cache = S3FIFO(size=10)# create a cache backed by your local flash, size is the number of objects in DRAM cachecache=S3FIFO(size=1000,flash_size_mb=1000,path="/disk/cachmon.data")# put an item into the cachecache.put("key","value")# or cache["key"] = "value"# you can specify a TTL using cache.put("key", "value", ttl=10)# get an item from the cachecache.get("key")# delete an item from the cachecache.delete("key")# or del cache["key"]# check if an item is in the cache"key"incache# or cache.has("key")# get the size of the cachelen(cache)# add a callback for evictiondefcallback(key,value,*args,**kwargs):print("key:{}, value:{}".format(key,value))cache.add_callback(callback)# list all items in the cacheprint(cache.items())# or print(cache.keys())# get some statprint(cache.stats())# or cache.miss_ratio()Cachemon can also be used as a decorator to cache the return value of a function similar to thefunctoolsin standard library.fromcachemonCacheimportS3FIFO@S3FIFO(size=1000,flash_size_mb=1000,path="/disk/cachmon.data")deffoo(x):returnx+1BenchmarkPython
RocksDBRoad mapsupport multi-threadingsupport flashContributingWe welcome contributions to Cachemon! Please check out ourcontributing guidefor more details.
Package: cacheobj
Cache object is general purpose object-property interface.NOTE: This library is under rebooting. Do not update from under 0.6.x if you mind continuous rewriting.ExampleThere is some pre-defined common types.in-memory, memcache and redis backends are included. And its common general interfaces too.>>> from cacheobj.redis import LocalRedisObject
>>> class UserCache(LocalRedisObject):
...   _properties = ['username', 'name']
...
>>> user = UserCache(id=10)
>>> print user.username
None
>>> user.username = 'username'
>>> user.name = 'Real Name'
>>> print user.username
username
>>> user10 = UserCache(id=10)
>>> print user10.username
usernameCache is stored with class name and given id.>>> print user.get('username', use_cache=True)
usernameIf you don’t want to hit backend again, there is use_cache option for local memory cache.For non-local cache backend, try a easy generator.>>> from cacheobj.redis import get_redis_object
>>> import redis
>>> MyRedisObject = get_redis_object(redis.ConnectionPool()) # any connection pool
>>> class MyUserCache(MyRedisObject):
...   pass
...Custom BackendUpper examples are shortcut for basic configuration.>>> from cacheobj import SimpleCacheObject
>>> from cacheobj.backend.memcache import MemcacheBackend
>>> def get_backend():
...   return MemcacheBackend(['127.0.0.1:11211'])
...
>>> class UserCache(SimpleCacheObject):
...   _backend_generator = staticmethod(get_backend)
...   _properties = ['username', 'name']
...This object works as upper UserCache object.
You can put custom backend with this.See source code to write a backend. It is just a few lines.Composite ExampleYou can composite multiple backends for an object.>>> from cacheobj import CacheObject
>>> from cacheobj.backend.memory import MemoryBackend
>>> from cacheobj.backend.memcache import MemcacheBackend
>>> from cacheobj.backend.redis import RedisBackend
>>>
>>> memory = MemoryBackend()
>>> memcache = MemcacheBackend()
>>> redis = RedisBackend()
>>>
>>> class CompositeCache(CacheObject):
... _backends = {
...   memory: ['mem1', 'mem2'],
...   memcache: ['mc1', 'mc2'],
...   redis: ['redis1', 'redis2'],
... }
...
>>> c = CompositeCache()
>>> c.mem1 # with backend memory
>>> c.mc1 # with backend memcache
>>> c.redis1 # with backend redis
Package: cacheorm
A cache-based python ORM -- supports Redis, Memcached.CacheBackendBaseBackendSimpleBackendRedisBackendMemcachedBackendMethodsset(key, value)get(key)delete(key)set_many(mapping)get_many(*keys)delete_many(*keys)has(key)SerializerjsonmsgpackpickleprotobufRegistryAll serializers are registered to a registry singleton.
Providejson,msgpack,picklethree preset serializers.You can register your own serializer,
such as a Protobuf serializer that registers aPersonmessage.registry.register("protobuf.person",ProtobufSerializer(person_pb2.Person))ModelBase
Package: cachephant
CachephantCachephant is a small python library which caches function output to disk to avoid unnecessary recomputation. It's aimed for use in Jupyter notebooks.ProblemThere's alreadyjoblib.Memoryanddiskcache.memoize. However, they didn't provide the behavior I desired (see table below):Joblib is very conservative and it's cache cannot be reused after restarting the Jupyter kernel. Moreover, unrelated code changes lead to cache invalidation.In contrast, diskcache is very liberal in its cache reuse and doesn't notice function code or signature changes. (This may be great for running a stable web app for weeks, but less idea for data science development.)uses cache if...joblibdiskcachecachephantJupyter kernel restartsnyysame "resolved" argumentsnn !ysome unrelated code changesnyysome related code changesnyy (n would be ideal but difficult)function code changesny !nfunction signature changesraises errory !nHow to useimportcachephantcache=cachephant.get_default_cache("/path/to/dir")@cachedefslow_function():time.sleep(10)return3You can also instantiatecachephant.Cache()and easily pass custom database-, file-, hash-, and evictor-classes.Non-goalsThis library is not meant for high frequency use cases (think hundreds of cache reads/writes per second) and you'll likely see performance issues.
Package: cachepot
cachepotYet another Python cache library. This has Python 3 typing hints.Installation$ pip install cachepotUsage>>>fromcachepot.storeimportCacheStore>>>fromcachepot.backend.filesystemimportFileSystemCacheBackend>>>fromcachepot.serializer.pickleimportPickleSerializer>>>store=CacheStore(...namespace='testing',...key_serializer=PickleSerializer(),...value_serializer=PickleSerializer(),...backend=FileSystemCacheBackend('/tmp'),...default_expire_seconds=3600,...)>>>store.put({'some':'key'},{'some':'value'})>>>store.get({'some':'key'}){'some':'value'}>>>store.put({'some':'short expiring key'},{'some':'value'},expire_seconds=10)Proxy methodresult=store.proxy(some_func)(some_args)is the equivalent ofresult=store.get(some_arg)ifresultisNone:result=some_func(some_args)store.set(result)In short, this works as proxy. This helps to make codes straight forward.
proxy method can be passed two argumentscache_keyandexpire_seconds.Core ideaSerializers convert python objects into bytes.
Backends save/load bytes.
So serializers and backends are independent.
CacheStore is the facade of them.Python3 typing supportsnamespacesProxy methodFeaturesSerializersstr ...cachepot.serializer.str.StringSerializerpickle...cachepot.serializer.pickle.PickleSerializerJSON...cachepot.serializer.json.JSONSerializerAnd more serializers you can define.BackendsSave to files ...cachepot.backend.filesystem.FileSystemCacheBackendSave to SQLite3 DB records ...cachepot.backend.sqlite.SQLiteCacheBackendSave to Redis DB ...cachepot.backend.redis.RedisCacheBackendOf course you can define own backend.DevelopmentYou can install requirements with poetry.$poetryinstallTest$poetrypoecheck# lint and type check$poetrypoetest# run testsLICENSEThe 3-Clause BSD License. See also LICENSE file.
Package: cacheproperty
cachepropertyA subclass of python’s builtin property class that removes boilerplate by implementing the h_hidden_attribute pattern with a single decorator call. Also afacilitates invalidation of the cached hidden attribute with a @cacheproperty.invalidate decorator on any other methods or properties in a class.Free software: GNU General Public License v3Documentation:https://cacheproperty.readthedocs.io.FeaturesCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2018-02-16)First release on PyPI.
Package: cacheproxy
CacheProxyA simple Python cache/caching proxy for Web development and something else, built onaiohttpandaiohttp-client-cache(a family project ofrequests-cache).Useful to avoid unfavorable massive accesses to external APIs during development, with little change, without preparing mocks. Not recommended for production.InstallpipinstallcacheproxyUsage1. Start up proxy$cacheproxysqlite-c./cache--expire-after1800Cachedatabase:/Users/nolze/src/cacheproxy/cache.sqlite========Runningonhttp://0.0.0.0:8080========(PressCTRL+Ctoquit)Other backends:cacheproxy# in-memorycacheproxymemory# in-memorycacheproxyfile-c./cache# file-based, saved under ./cache/cacheproxysqlite-c./cache# sqlite, saved to ./cache.sqlite2. Access through proxycURL:curlhttp://0.0.0.0:8080/api.github.com/repos/nolze/cacheproxy# This request is cached until the expiration time# → {"id":...,"node_id":"...","name":"cacheproxy", ...Python (requests):importrequestsbase_url="http://0.0.0.0:8080/api.github.com"# Just replace with "https://api.github.com" on productionresp=requests.get(f"{base_url}/repos/nolze/cacheproxy")# or use urljoin()print(resp.json())# → {'id': ...., 'node_id': '....', 'name': 'cacheproxy', ...JavaScript/Node:constbaseURL="http://0.0.0.0:8080/api.github.com";// Just replace with "https://api.github.com" on productionconstresp=awaitfetch(`${baseURL}/repos/nolze/cacheproxy`);constdata=awaitresp.json();console.log(data);// → Object { id: ..., node_id: "...", name: "cacheproxy", ...Interact with or modify cached dataUseaiohttp-client-cacheto load existing databases.See also:https://aiohttp-client-cache.readthedocs.io/TodosBetter error handlingWrite testsBetter loggingSupport POST/PUTSupport switching http/https (with --http/--https flags)Support DynamoDB, MongoDB, and Redis backendsLicenseMIT
Package: cache-result
Cache Function Result描述这个Python包专门设计用于缓存函数的返回结果，以便于将结果持久化并保存在本地。它能够基于函数的参数内容和代码变动来判定是否需要读取已有的缓存。设计理念持久性保障：函数运行的结果将永久保存，除非用户主动删除缓存。灵活分类存储：缓存结果可以按重要程度存储在不同的子文件夹中，便于管理和控制。手动控制更新：若需要重新运行函数以获得最新结果，用户只需手动删除相应的缓存文件。应用场景加速计算处理：对于耗时较长的计算密集型函数，可以通过缓存其结果，以便下次调用时能够迅速获取到。稳定数据获取：对于从网络获取数据的函数，如果获取的内容通常不会发生变化，可以通过缓存来保存结果。一旦数据有所改变，用户可以手动删除缓存以更新数据。优化开发效率：在开发大型语言模型时，可以通过缓存接口数据来节省成本并加快响应速度。功能特点灵活的缓存位置设置：用户可以自由指定缓存保存的位置，并且随时更改位置设置。共享缓存内容：缓存的内容可以轻松分享给他人，使其他用户也能够利用已有的缓存数据。按参数名称分类缓存：可以根据不同的参数名称将缓存保存在不同的文件夹中，便于管理和检索。时间驱动的缓存管理：实现了基于时间的缓存控制，允许用户根据日期和时间来组织缓存文件，从而使得缓存管理更加高效和直观。这一特性特别适用于需要定期更新或具有时间敏感性的数据缓存。安装指南此包可通过pip进行安装：pipinstallcache_result快速使用注意事项：需要在项目根目录创建一个.projectroot文件，用来标识项目的根目录，这样缓存文件都会创建到根目录importtimefromcache_resultimportcache@cache()defadd(a,b):time.sleep(4)returna+bprint("第一次运行需要花费4秒，再次运行只需要瞬间")print(add(1,2))参数详解代码包含设置(has_source_code): 决定是否在缓存中包含函数的源代码。默认为false，此时缓存将仅包含代码体，且忽略代码中的输出注释。缓存位置提示(is_print): 控制是否输出缓存文件的位置信息。默认设置为true，便于用户了解缓存文件的存储位置。参数排除选项(exclude_args): 允许用户排除特定参数，避免某些参数被包含在缓存中。默认为空，即不排除任何参数。调试模式(debug): 启用此模式将开启详细的日志记录，方便调试和追踪问题。默认为false。哈希长度设置(hash_length): 定义生成的缓存文件名的长度。默认长度为16。更多用法注意事项：需要在项目根目录创建一个.projectroot文件，用来标识项目的根目录，这样缓存文件都会创建到根目录分文件缓存可以通过设置路径，添加不同的文件，并且文件的名称可以使用占位符缓存的计算斐波那契数列的第n项，可以通过设置占位符，来让不同的结果缓存到不同的文件夹中。importtimefromcache_resultimportcache@cache('cache/fib/{n}')deffib(n):"""计算斐波那契数列的第n项"""ifn<2:returnnelse:returnfib(n-1)+fib(n-2)if__name__=='__main__':print("计算斐波那契数列花费时间：")# 测试函数start=time.time()print(fib(40))# 第一次计算将花费一些时间print('Time: ',time.time()-start)print("如果cache中有缓存结果了，再次运行会非常快")print("删除cache中的内容即可重新执行函数")按时间缓存如果需要按照时间让缓存失效，例如一天，一周，或者一小时添加按时间缓存，允许根据日期和时间来组织缓存文件，从而使得缓存管理更加高效和直观。 完整的时间格式，可以自己控制：{time:YYYY-MM-DD_HH-mm-ss}下面的写法是缓存一个小时importtimefromcache_resultimportcache@cache("cache/{time:YYYY-MM-DD_HH}")defadd(a,b):time.sleep(4)returna+bprint("第一次运行需要花费4秒，在一个小时内运行，只需要瞬间")print(add(1,2))排除某些参数如果输入的参数不会影响输出的结果，可以进行排除，这样他的改变不会导致重新计算缓存importtimefromcache_resultimportcache@cache("cache/{time:YYYY-MM-DD_HH}",exclude_args=['sleep'])defadd(a,b,sleep=4):time.sleep(sleep)returna+bprint("排除了sleep参数的影响，他的改变不会导致重新缓存")print(add(1,2))print(add(1,2,sleep=2))高级用法缓存目录的层级是方便用户区分的，缓存文件生成以后可以任意的修改缓存目录的层级，例如原来的缓存目录为cache/a可以直接改为cache/b然后把本地的缓存文件手动从a复制到bLicenseThis project is licensed under the MIT License.
Package: cache-simulator
Copyright 2015-2018 Caleb EvansReleased under the MIT licenseBuild StatusCoverage
StatusThis program simulates a processor cache for the MIPS instruction set
architecture. It can simulate all three fundamental caching schemes:
direct-mapped,n-way set associative, and fully associative.The program must be run from the command line and requires Python 3.4+
to run. Executing the program will run the simulation and print an ASCII
table containing the details for each supplied word address, as well as
the final contents of the cache.To see example input and output, seeexamples.txt.InstallingYou can install Cache Simulator via pip (ideally globally):pip install cache-simulatorCommand-line parametersRequired parameters–cache-sizeThe size of the cache in words (recall that one word is four bytes in
MIPS).–word-addrsOne or more word addresses (separated by spaces), where each word
address is a base-10 positive integer.Optional parameters–num-blocks-per-setThe program internally represents all cache schemes using a set
associative cache. A value of1for this parameter (the default)
implies a direct-mapped cache. A value other than1implies either a
set associativeorfully associative cache.–num-words-per-blockThe number of words to store for each block in the cache; the default
value is1.–num-addr-bitsThe number of bits used to represent each given word address; this value
is reflected in theBinAddrcolumn in the reference table. If omitted,
the default value is the number of bits needed to represent the largest
of the given word addresses.–replacement-policyThe replacement policy to use for the cache. Accepted values arelru(Least Recently Used; the default) andmru(Most Recently Used).
Package: cachestore
CacheStoreCacheStoreis a simple cache management system for Python functions.
You can reuse the cached results even accross different executions.cachestorecommand enables you to manage the cached results from command line.
Please see--helpfor more details.FeaturesCaching execution results by decorating target functions easilyExporting caches into an external storage to reuse them access different exeutionsDetecting appropreate caches based on argumetns/source code of functionsChanging cache behavior via configuration file (seeexmaples)Providing a useful command line tool to manage cachesWritten in pure Python, no external dependenciesInstallationpipinstallcachestoreUsagePythonfromcachestoreimportCachecache=Cache()@cache()defawesome_function(x,*,y="y",**kwargs):...CLI$cachestore--help
usage:cachestore

positionalarguments:{list,prune,remove}optionalarguments:-h,--helpshowthishelpmessageandexit--versionshowprogram'sversionnumberandexit
Package: cache-to-disk
cache_to_diskLocal disk caching decorator for python functions with auto-invalidation.This is intended to cache functions that both take a long time to run, and have return values that take up too much memory to cache in-memory with redis. The results of the function are pickled and saved to a file, and then unpickled and returned the next time the function is called. The caching is argument specific, so if the function is called with different arguments, the function will be run again. The caching decorator accepts an integer representing the number of days to cache the function for. After this many days, the file for that function will be deleted the next time this module is imported.Installationpipinstallcache_to_diskFunctions:cache_to_disk(n_days_to_cache)
delete_disk_caches_for_function(function_name)
delete_old_disk_caches()Examples:cache_to_disk"""This example caches the function "my_function" for 3 days."""fromcache_to_diskimportcache_to_disk@cache_to_disk(3)defmy_function():to_return=[]foriinrange(10000):forjinrange(i):to_return.append(i*j**.23)returnto_returndelete_disk_caches_for_function"""This example invalidates all of the caches for the function "my_function". The function will be invalidated automatically, but this should be used when the function definition has been changed and you want it to re-run."""fromcache_to_diskimportdelete_disk_caches_for_functiondelete_disk_caches_for_function('my_function')runtime_accounting"""This example shows how to check the run-time cache accounting, which shows hits, misses and nocache events"""fromcache_to_diskimportcache_to_disk@cache_to_disk(3)defquery_registrar(host,port,query):socket=tcp_connect(host,port)socket.send(query)response=b''whileTrue:buf=read_wrapper(socket)ifbufisNone:breakresponse+=bufreturnresponsequery_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')print(query_registrar.cache_info())nocache"""This example shows how to inhibit caching depending on certain conditions, such as a network failure while also returning a value"""fromcache_to_diskimportcache_to_disk,NoCacheConditionfromrandomimportrandint@cache_to_disk(3)defquery_registrar(host,port,query):socket=tcp_connect(host,port)socket.send(query)response=b''whileTrue:try:ifrandint(0,5)>3:# Simulate a spurious failure like SIGPIPE/EPIPEraisesocket.errorbuf=read_wrapper(socket)ifbufisNone:breakresponse+=bufexceptsocket.error:# To the user, functionalliy requivalent to `return response` except# the result is not cached, so it can be retried immediately or laterraiseNoCacheCondition(function_value=response)returnresponsequery_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')query_registrar('whois.verisign-grs.com',43,b'test.com')print(query_registrar.cache_info())
Package: cachetools
This module provides various memoizing collections and decorators,
including variants of the Python Standard Library’s@lru_cachefunction decorator.fromcachetoolsimportcached,LRUCache,TTLCache# speed up calculating Fibonacci numbers with dynamic programming@cached(cache={})deffib(n):returnnifn<2elsefib(n-1)+fib(n-2)# cache least recently used Python Enhancement Proposals@cached(cache=LRUCache(maxsize=32))defget_pep(num):url='http://www.python.org/dev/peps/pep-%04d/'%numwithurllib.request.urlopen(url)ass:returns.read()# cache weather data for no longer than ten minutes@cached(cache=TTLCache(maxsize=1024,ttl=600))defget_weather(place):returnowm.weather_at_place(place).get_weather()For the purpose of this module, acacheis amutablemappingof a
fixed maximum size.  When the cache is full, i.e. by adding another
item the cache would exceed its maximum size, the cache must choose
which item(s) to discard based on a suitablecache algorithm.This module provides multiple cache classes based on different cache
algorithms, as well as decorators for easily memoizing function and
method calls.Installationcachetools is available fromPyPIand can be installed by running:pip install cachetoolsTyping stubs for this package are provided bytypeshedand can be
installed by running:pip install types-cachetoolsProject ResourcesDocumentationIssue trackerSource codeChange logRelated Projectsasyncache: Helpers to use cachetools with async functionscacheing: Pure Python Cacheing LibraryCacheToolsUtils: Cachetools Utilitieskids.cache: Kids caching libraryshelved-cache: Persistent cache for Python cachetoolsLicenseCopyright (c) 2014-2024 Thomas Kemmer.Licensed under theMIT License.