Saravanan666/pypi-org huggingface dataset:
Package: cache3
cache3: Python3 cache librarycache3is a MIT licensed  safe and lightweight cache library, written
in pure-Python.cache3 is very tiny and completely implemented by the Python standard library without any third-party dependencies, so it can be easily embedded in any Python program or script.Installingcache3 is available from PyPI and can be installed by running:pipinstall-Ucache3or download the file and install it locally$gitclonehttps://github.com/StKali/cache3.git$cdcache3$pythonsetup.pyinstallFeaturePure-PythonThread-safe and process-safeHigh performance100% test coverageExtension friendlySupports multiple data typesCompatible with all platformsLinksDocumentation:https://stkali.github.io/cache3/PyPI Releases:https://pypi.org/project/cache3Source Code:https://github.com/StKali/cache3Issue Tracker:https://github.com/StKali/cache3/issuesLicenseCopyright (c) 2020-2023clarkmonkey@163.comLicensed under the MIT License.
Package: cache4py
cache4py: Caching simplified.Getting startedInstallationInstall using pip:$ pip install cache4pyUsagefromcache4py.decoratorsimportcachefromcache4py.storage.redisimportRedisBackend# You can choose memcached, redis or default (python's dict) as a backend.redis_backend=RedisBackend(url='localhost',port='6379')@cache(backend=redis_backend)defmy_function_one(*args,**kwargs):# do something awesomereturnOptionsKeysEviction policies (coming soon)BackendMax memory limit (coming soon)Key expiry time (coming soon)Contributing to cache4pyRefer CONTRIBUTING.mdIssue trackingCreate issues atcache4py/issues.AuthorsNitin Labhishetty (lnitin94@gmail.com)Vaibhav Tulsyan (vstulsyan@gmail.com)
Package: cache-alchemy
Cache AlchemyThe Python Cache Toolkit.Free software: MIT licenseDocumentation:https://cache-alchemy.readthedocs.io/en/latest/Installation$pipenvinstallcache-alchemy✨🍰✨OnlyPython 3.6+is supported.ExampleimportdataclassesfromredisimportRedisfromcache_alchemyimportmemory_cache,json_cache,pickle_cachefromcache_alchemy.configimportDefaultConfigconfig=DefaultConfig()config.cache_redis_client=Redis.from_url(config.CACHE_ALCHEMY_REDIS_URL)@dataclasses.dataclassclassUser:name:str@pickle_cache()defget(name:str)->User:returnUser(name=name)@memory_cache()defadd(i:complex,j:complex)->complex:returni+j@json_cache()defadd(i:int,j:int)->int:returni+jFeaturesDistributed cacheCache clear and partial clear with specific function parameterCache clear cascade by dependencyCacheJson Serializablefunction return value withjson_cacheCache Python Object function return value withpickle_cacheCache any function return value withmemory_cacheLRU Dict supportTODOHistory0.4.* (2020)Refactory redis cache to json cacheSupport pickle CacheAdd backend class in function hashAdd cache key prefix to avoid key conflict0.2.* (2019)Support Partially Clear Cache with ArgumentsSupport Flush Backend CacheCache Redis Client Must Decode Responses0.1.* (2019)Support Method and Property CacheSupport cache as a decorator with no arguments.Init Project.
Package: cacheblob
python-cacheblobcacheblob is a key-value interface for expiring items.Installationpip install python-cacheblobUsageimportdatetimefromcacheblobimportCacheblobcache=Cacheblob.cache(handler='mongo')cache.store(index='index2',value='value2',duration=datetime.timedelta(days=1))foritemincache.fetch_all():printitemUse Casecacheblob was designed for data sources that should age and expire. Using it should be as
simple as setting an expiry time (or duration) on your data.As such, cacheblob avoids imposing too many design decisions upon the user beyond those
necessary for its expiry functionality. It decouples the interface and the storage
mechanism by allowing arbitrary underlying storage systems, calledhandlersin
cacheblob.Cacheblob has anitemconcept, which is a key-value pair with an expiry time. Most
handlers except strings for values or will work with any values that can be converted to
strings. Not all handlers are necessarily subject to this limitation.Cacheblob was designed to be lightweight by default, and to be flexible, by allowing the
user to choose their underlying storage model. Worried about concurrency? Use a handler
that allows concurrent access. You want your items as files on disk for easy access by
programs that expect them as such? Use a file-backed handler. Choose your own
consistency-availability-tolerance trade-off.The current implemented handlers are:handler: A lightweight wrapper that uses Python’s in-memory storagemongo: Store items in a Mongo databasesqlite: Store items in a SQLite databaseplaintext: Store items as files in a folder on diskgzip: Store items as gzip files in a folder on diskAuthorsrdj -https://oddacious.github.ioChangelog0.1.0 (2016-11-01)First PyPi release0.1.0a1 (2016-09-10)Prerelease
Package: cachebust
Cachebust provides a server-side means to ensure that clients always fetch assets when they are updated on the server.Many browsers have different means of caching, some will overcache, and using the HTTP cache headers, there’s always a chance you may need to update within the lifetime of the previous scripts.cachebust provides a means to ensure that all assets are fetched by browsers when they are updated. The way it works, is that it takes HTML (via a library or commandline tool) and modifies the asset hrefs, adding a parameter “cachebust” equal to the md5sum of the file.When the file changes, the md5sum will change, and the browser sees this as a distinct document, and will fetch the update no matter what its caching policy.UsageUsage: cacheBust (options) [input]Options:-r or --asset-root       Specify the filesystem root which should be treated as “/” for links. Default is cwd-e or --encoding         Specify the encoding to use (default, utf-8)-q or --quiet            Do not print errors to stderr when cannot cachebust an element--help                   Show this messageLibrary DocumentationCan be found at:http://htmlpreview.github.io/?https://github.com/kata198/cachebust/blob/master/doc/cachebust.html
Package: cache-by-key
cache-by-keycache-by-key is a lru based cache that allows you to cache by specific keyword argument from a decorated function.
On top of it, each keyword argument's cache can have at most 10 different LRU caches.InstallationYou can install via pip using command shown below.pip install cache-by-keyDocumentationFor full documentation, visitcache-by-key.readthedocs.io.
Package: cache-client
Cache-ClientCache-Clientmost of the time, you need cache to some kind of backend to speed up your app.this framework add these tools to free you from write these.it also has auto update function to free you from manually update something.UsagefromloggingimportStreamHandlerimportasyncioimporttimefromcache_client.client.commonimportSimpleClientimportlogginglogger=logging.getLogger(__package__)handler=StreamHandler()handler.setLevel(logging.DEBUG)logger.addHandler(handler)logger.setLevel(logging.DEBUG)mysql_conf={'host':'127.0.0.1','port':3306,'db':'test','user':'test','password':'test'}redis_conf={'redis_host':'127.0.0.1','redis_port':6379,'redis_secret':'',}client=SimpleClient(backend_conf=mysql_conf,cache_conf=redis_conf,update_interval=30)asyncdeftest():awaitclient.connect()expire_at=int(time.time())+100foriinrange(10):start=int(time.time()*1000)result=awaitclient.get(database='sku',key='select sku_id,description,price,status from sku',expire_at=expire_at,update_interval=100)end=int(time.time()*1000)print('running time',end-start)print(result,'result',i)loop=asyncio.get_event_loop()# loop.run_until_complete(test())loop.create_task(test())loop.run_forever()Codinglike this project, star itany suggestion is welcomethis project is under MIT lisensemore docs are writing.
Package: cachecontrol-django
cachecontrol-djangoA cache provider forCacheControlusing Django's caching mechanism.Installationpip install cachecontrol-djangoUsageimportrequestsfromcachecontrolimportCacheControlfromcachecontrol_djangoimportDjangoCachesession=CacheControl(requests.session(),cache=DjangoCache())session.get("https://www.glassesdirect.co.uk/")Working Around Key Length ErrorsIf you see errors about key length (such as "MemcachedKeyLengthError: Key length is > 250"), you can ask DjangoCache to hash the keys it uses by specifying akey_hash_algorithm:long_url='https://www.glassesdirect.co.uk/?q='+('x'*250)session=CacheControl(requests.session(),cache=DjangoCache(key_hash_algorithm='sha512'))session.get(long_url)Note that when hashing these keys, there is a very small chance of a hash collision causing a request for one URL to return the content of another.
Package: cachecontrol-uwsgi
cachecontrol-uwsgiBackend forCacheControlusinguwsgi's caching framework.Only works inside of uWSGI (theuwsgimodule must be importable), and needs a configured cache (see uWSGI's--cache2option) to work.For an example uWSGI setup with a working cache, seetest_app.pyandits integration testsinside the repository. It's a test application that doesn't use CacheControl but has a configured cache that works.UsageimportrequestsfromcachecontrolimportCacheControlfromcachecontrol_uwsgiimportUWSGICachecached_session=CacheControl(requests.session(),cache=UWSGICache("cache_name"))response=cached_session.get("http://httpbin.org/status/200")
Package: cachecore
cachecoreA low-level caching library with multiple implementations.Can be used as a stand-alone cacheing library or can be used to create higher level caching libraries.BasicsGet, set, delete, and check for the existence of a key using the following.>>> import cachecore
>>> cache = cachecore.LocalCache()
>>> cache.set('a', 1)
>>> cache.get('a')
1
>>> cache.exists('a')
True
>>> cache.delete('a')
True
>>> cache.exists('a')
False
>>> cache.get('a')
NoneComplete API__getitem__(self, key: str) -> Any:

    __setitem__(self, key: str, value: Any):

    __delitem__(self, key: str):

    __contains__(self, key: str):

    __iter__(self):

    __len__(self):

    keys(self, pattern: str = None):

    get(self, key: str, default: Any = None) -> Any:

    set(self, key: str, value: Any, ttl: Optional[int] = None):

    add(self, key: str, value: Any, ttl: Optional[int] = None) -> bool:

    replace(self, key: str, value: Any, ttl: Optional[int] = KEEP_TTL) -> bool:

    delete(self, key: str) -> bool:

    pop(self, key: str, default: Any = None):

    exists(self, key: str) -> bool:

    get_many(self, keys: Iterable[str], default: Any = None) -> Iterable[Any]:

    set_many(self, mapping: Iterable[tuple[str, Any]], ttl: Optional[int] = None):

    delete_many(self, keys: Iterable[str]) -> Iterable[bool]:

    get_ttl(self, key: str, default: int = 0) -> Optional[int]:

    set_ttl(self, key: str, ttl: Optional[int] = None) -> bool:

    incr(self, key, delta=1) -> int:

    decr(self, key, delta=1) -> int:

    clear(self):Cache ImplementationsRedisMemcachedFile SystemLocal MemoryDummy
Package: cache-df
Cache Pandas Dataframes to DiskEasily cache Pandas Dataframes to disk using a simple interface.Sample usagefromcache_dfimportCacheDFimportpandasaspdcache=CacheDF(cache_dir='./caches')# Caching a dataframedf=pd.DataFrame({'a':[1,2,3],'b':[4,5,6]})cache.cache(df,'my_df')# Checking if a dataframe is cacheddf_is_cached=cache.is_cached('my_df')# Reading a dataframe from cachetry:df=cache.read('my_df')df_selective_cols=cache.read('my_df',columns=['a'])# Read only a subset of columnsexceptFileNotFoundError:print('Dataframe not cached')# Deleting a dataframe from cache if it existscache.uncache('my_df')# Clearing all cached dataframescache.clear()Where it can be usedIt can be used when you are using a shared file system across multiple machines such as AWS EFS, GCP Filestore, Azure Files, etc.
Package: cached-historical-data-fetcher
Cached Historical Data FetcherPython utility for fetching any historical data using caching.
Suitable for acquiring data that is added frequently and incrementally, e.g. news, posts, weather, etc.InstallationInstall this via pip (or your favourite package manager):pipinstallcached-historical-data-fetcherFeaturesUses cache built on top ofjoblib,lz4andaiofiles.Ready to use withasyncio,aiohttp,aiohttp-client-cache. Usesasyncio.gatherfor fetching chunks in parallel. (For performance reasons, only usingaiohttp-client-cacheis probably not a good idea when fetching large number of chunks (web requests).)Based onpandasand supportsMultiIndex.UsageHistoricalDataCache,HistoricalDataCacheWithChunkandHistoricalDataCacheWithFixedChunkOverrideget_one()method to fetch data for one chunk.update()method will callget_one()for each unfetched chunk and concatenate results, then save to cache.fromcached_historical_data_fetcherimportHistoricalDataCacheWithFixedChunkfrompandasimportDataFrame,Timedelta,TimestampfromtypingimportAny# define cache classclassMyCacheWithFixedChunk(HistoricalDataCacheWithFixedChunk[Timestamp,Timedelta,Any]):delay_seconds=0.0# delay between chunks (requests) in secondsinterval=Timedelta(days=1)# interval between chunks, can be any typestart_index=Timestamp.utcnow().floor("10D")# start index, can be any typeasyncdefget_one(self,start:Timestamp,*args:Any,**kwargs:Any)->DataFrame:"""Fetch data for one chunk."""returnDataFrame({"day":[start.day]},index=[start])# get complete dataprint(awaitMyCacheWithFixedChunk().update())day2023-09-3000:00:00+00:00302023-10-0100:00:00+00:0012023-10-0200:00:00+00:002Seeexample.ipynbfor real-world example.IdCacheWithFixedChunkOverrideget_onemethod to fetch data for one chunk in the same way as inHistoricalDataCacheWithFixedChunk.
After updatingidsby callingset_ids(),update()method will callget_one()for every unfetched id and concatenate results, then save to cache.fromcached_historical_data_fetcherimportIdCacheWithFixedChunkfrompandasimportDataFramefromtypingimportAnyclassMyIdCache(IdCacheWithFixedChunk[str,Any]):delay_seconds=0.0# delay between chunks (requests) in secondsasyncdefget_one(self,start:str,*args:Any,**kwargs:Any)->DataFrame:"""Fetch data for one chunk."""returnDataFrame({"id+hello":[start+"+hello"]},index=[start])cache=MyIdCache()# create cachecache.set_ids(["a"])# set idscache.set_ids(["b"])# set ids again, now `cache.ids` is ["a", "b"]print(awaitcache.update(reload=True))# discard previous cache and fetch againcache.set_ids(["b","c"])# set ids again, now `cache.ids` is ["a", "b", "c"]print(awaitcache.update())# fetch only new dataid+helloaa+hellobb+helloid+helloaa+hellobb+hellocc+helloContributors ✨Thanks goes to these wonderful people (emoji key):This project follows theall-contributorsspecification. Contributions of any kind welcome!
Package: cached-http-fetcher
Cached http fetcherThis library fetches data via HTTP(S), stores into some storages which is accessible from the internet.Installpipinstallcached-http-fetcherUsageThe standard way to use this library is store metadata in Redis and store images itself in S3. The images in S3 can be accessed by the internet.You have to implement your own meta storage extendsMetaStorageBasewith Redis and content storage extendsContentStorageBasewith S3.The whole sample code is following, or see and executefetch_with_memory.py.importboto3fromredisimportRedisimportcached_http_fetcherfromurllib.parseimporturlsplit,quotefromtypingimportOptional,Iterablefrombotocore.exceptionsimportClientErrorimportloggingclassRedisMetaStorage(cached_http_fetcher.MetaStorageBase):def__init__(self,settings):self.redis=Redis.from_url("redis://redis:6379/0")defget(self,source_url:str)->Optional[bytes]:returnself.redis.get(source_url)defdelete(self,source_url:str)->None:self.redis.delete(source_url)defput(self,source_url:str,value:bytes)->None:self.redis.set(source_url,value)classS3ContentStorage(cached_http_fetcher.ContentStorageBase):def__init__(self,settings):self.s3=boto3.client("s3")self.bucket="some-bucket"@staticmethoddefs3_key(source_url:str):r=urlsplit(source_url)s3_key="path-prefix/"url=''ifr.scheme=="http":passelifr.scheme=="https":s3_key+='s/'else:raiseValueErrors3_key+=r.netloc+r.pathifr.query:s3_key+="?"+r.queryreturnquote(s3_key)defget(self,source_url:str)->bytes:try:obj=self.s3.get_object(Bucket=self.buclet,Key=S3ContentStorage.s3_key(source_url))returnobj["Body"]exceptClientErrorasex:ifex.response["Error"]["Code"]=="NoSuchKey":returnNoneelse:raisedefdelete(self,source_url:str)->None:self.client.delete_object(Bucket=self.bucket,Key=S3ContentStorage.s3_key(source_url))defput_content(self,source_url:str,value:bytes,cache_control:str,content_type:Optional[str]=None)->None:config=dict(ACL="bucket-owner-full-control",Bucket=self.bucket,Key=key,CacheControl=cache_control,Body=value)ifcontent_type:config["ContentType"]=content_typeself.s3.put_object(**config)defcached_url(self,source_url:str)->str:returnf"https://{self.bucket}.s3.us-west-2.amazonaws.com/{S3ContentStorage.s3_key(source_url)}"url_list=["http://www.example.com/image1.jpg","http://www.example.com/image2.jpg"]meta_storage=RedisMetaStorage(settings)content_storage=S3ContentStorage(settings)logger=logging.getLogger(__name__)cached_http_fetcher.fetch_urls(url_list,meta_storage,content_storage,logger=logger)forurlinurl_list:meta=cached_http_fetcher.get_meta(url,meta_storage,logger=logger)print(meta.cached_url)Developmaketest# testmakedist# release to PyPI
Package: cached-ipaddress
cached-ipaddressSource Code:https://github.com/bdraco/cached-ipaddressCache construction of ipaddress objectsDesignThis module keeps a cache of IPAddress objects and caches the properties on them.It it useful when you frequently see the same ip addresses over and over and
do not want to pay the overhead of constructing IPAddress objects over and over
or checking their properties.InstallationInstall this via pip (or your favourite package manager):pip install cached-ipaddressUsagefromcached_ipaddressimportcached_ip_addressesip=cached_ip_addresses("127.0.0.1")assertip.is_loopbackisFalseinvalid=cached_ip_addresses("invalid")assertinvalidisNoneContributors ✨Thanks goes to these wonderful people (emoji key):This project follows theall-contributorsspecification. Contributions of any kind welcome!CreditsThis package was created withCopierand thebrowniebroke/pypackage-templateproject template.
Package: cachedir-tag
CACHEDIR.TAG for PythonThis library handlesCACHEDIR.TAGfiles.
Allowing any arbitrary directory to be marked as a cache directory.A CACHEDIR.TAG file indicates a directory that contain cached data, e.g.downloadspreviews, and thumbnailsbuild artefacts, and other intermediate resultsCached data is useful, but not essential - if necessary it can be regenerated,
or downloaded again. However backup programs, disk cleanup utilities, & other
software can't know if an arbitrary path is cached data, unless it is marked.A directory (and all directories within it) can be marked as a cache by
writing a regular file named CACHEDIR.TAG, with the first 43 bytes beingSignature: 8a477f597d28d172789f06886806bc55After this signature any other text can be included. The specification
suggests lines of text beginning with#, encoded as UTF-8. E.g.# This file is a cache directory tag created by (application name).
# For information about cache directory tags, see:
#	http://www.brynosaurus.com/cachedir/This library follows that suggestion.Installation$ python -m pip install cachedir-tagUsageCreate your cache directory, if necessary>>>importos,cachedir_tag>>>os.mkdir('/var/cache/yourapp')Tag it, this creates a new CACHEDIR.TAG file>>>cachedir_tag.tag('/var/cache/yourapp')Check whether the directory is tagged>>>cachedir_tag.is_tagged('/var/cache/yourapp')TrueCheck whether a sub-directory (which may not exist yet) is tagged>>>cachedir_tag.is_tagged('/var/cache/yourapp/somedir')TrueAlternativesOperating systems and similar platforms usually have conventions about where
to place cached data. A CACHEDIR.TAG file isn't needed if you follow these
conventions, but it doesn't hurt either.More informationCache Directory Tagging SpecificationbyBryan Ford
Package: cached-markdown-field
CachedMarkdownField for Django ModelsThis Field caches compiled Markdown and then uses the cached value when queried. This saves time spent compiling Markdown on every request.ExampleclassNameAndDescription(models.Model):name=CharField(max_length=20)description=CachedMarkdownField()instance=NameAndDescription()instance.description="text"assertinstance.description=="<p>text</p>"SettingsCachedMarkdownFieldrecongnized twoSETTINGS.pysettings# Enables cachingMARKDOWN_CACHE=True# If false, will raise error if not already compiledMARKDOWN_CACHE_RUNTIME=TrueHow does it work?InternallyCachedMarkdownFieldusesCompositeFieldand stores the cached value in separate field.CachedMarkdownFieldis a proxy and will add two fields into the actual model. In the example
aboveinstance.descriptionreturns a proxy object that maps the fieldsmarkdownandcachedto the model fieldsdescription_markdownanddescription_cached.
Package: cached_method
cached_methodThe@cached_methoddecorator is the equivalent offunctools.cached_propertyfor methods. This means that each instance has its own cache, so that the caches get
garbage collected as soon as the owning objects are. The main advantages ofcached_methodover applyingfunctools.lru_cachedirectly to methods arethe surrounding class need not be hashable,and the class objects are not collected in a global cache, extending their lifetime.
This makescached_methodapplicable to classes holding references to scarce resources
such as GPU memory that you want to be freed as soon as possible. Furthermore, the
decorator can cache the output of__hash__because it does not hash the object itself
for cache lookups.Implementation-wisecached_methodclosely followsfunctools.cached_propertythough it
eschews the internal locking, which is nowconsidered a
mistake. Since cached methods should be idempotent
anyway, we just accept possibly calling the method multiple times in parallel with
equivalent arguments if the object is used in multi-threaded contexts.fromcached_methodimportcached_methodclassGPUVector:def__init__(self,data):# data is some smart tensor object as found in pytorch, tensorflow, etc.self.data=data# Only cache the 2 most-recently used norms@cached_method(maxsize=2)defnorm(self,p=2):return(self.data**p).sum()**(1/p)@cached_methoddef__hash__(self):# A costly GPU-to-CPU transfer, so we want to hash the resultreturnhash(tuple(self.data.to_cpu()))If you are working with small, hashable objects that do not have to be gargabe collected
as soon as possible, consider themethod hashing technique described in the Python
FAQ. It gives
you an easy way to control the total cache size and allows cache hits between
equivalent-but-not-identical objects. Of course, caching on the class level means that
objects stay live until you clear the cache manually, even if the cache is the last object
referencing them.