Skip to main content

AioCacheBucket

这并非一个使用类似 result = await cache.get("xxxxxx") 的所谓" IO密集型" 应用.
AioCacheBucket 是使用了 asyncio 模块的多种技巧实现的一个Python缓存模块.

Example

# 单实例:
from AioCacheBucket import AioCacheBucket

bucket = AioCacheBucket()
bucket.set("message", "Hello World!")
print(bucket.get("message"))

# 多实例:
from AioCacheBucket import AioMultiCacheBucket

multibuckets = AioMultiCacheBucket({})
multibuckets.setup({
    "hello-world": {}
})
hello_world_bucket: AioCacheBucket = multibuckets.getBucket("hello-world")
hello_world_bucket.set("message".encode("utf-8"), "sth.") # 除了键必须是hashable, 值则可以是任何PyObject.

# 即时过期机制:
from datetime import datetime as dt, timedelta as td
bucket.set("ttl-test", "sth", date=dt.now() + td(seconds=10))
# ttl-test这个键会在10秒后被删除. ACB会在你使用get方法时检查键的过期情况, 并根据其进行一定处理.

multibuckets.close_scavenger() 
# 在执行完所有代码后, 请先通过该方法停止内置的清道夫线程, 否则可能导致假死
# 在这之后我们可能会使用atexit等模块实现自动执行该方法.

ACB主要将 asyncio 模块用于清道夫线程的实现, 对于用户接口尽量做到简单方便.

强烈推荐在Python 3.7.10及以上版本使用该模块.

Metadata

Release files for AioCacheBucket 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AioCacheBucket 0.0.7
File Size Uploaded Provenance
AioCacheBucket-0.0.7.tar.gz 4.5 kB Without provenance Details

Release files / AioCacheBucket-0.0.7.tar.gz

Download URL AioCacheBucket-0.0.7.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bf3d74728fc036dbe07e3b1cdd1b29d298c03ed2fe552adc6ab0f0c9963ab18b
BLAKE2b-256 checksum
How to use checksums
721bbb33b7a95eec9d5c0178434c50cf628399ab371aa70481fd56d8139202e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Security for AioCacheBucket 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page