Skip to main content

English 简体中文

efcCache

efcCache is a general-purpose cache library that supports multiple storage backends, including:

  • Local file
  • SQLite
  • MySQL
  • PostgreSQL
  • Redis

Installation

Install efcCache using pip:

pip install efcCache

Quick Start

Here's a simple example of using efcCache:

import efcCache
from efcCache.providers.FileCache import FileCache

# Create a cache manager
cacheManager = efcCache.CacheManager(default_storage="local")

# Set up storage backend
cacheManager.set_storage("local", FileCache(storage_path="./storage/"))

# Use the cache class
print("Testing file cache:")
cacheManager.set("test", "File cache test")
print(cacheManager.get("test"))
print(cacheManager.exists("test"))
cacheManager.delete("test")
print(cacheManager.exists("test"))

Importing other cache providers:

import efcCache
from efcCache.providers.FileCache import FileCache
from efcCache.providers.SQLiteCache import SQLiteCache
from efcCache.providers.RedisCache import RedisCache
from efcCache.providers.MySQLCache import MySQLCache
from efcCache.providers.PostgreSQLCache import PostgreSQLCache

# Create a cache manager
manager = efcCache.CacheManager(default_storage="local")

# Set up storage backends
manager.set_storage("local", FileCache(storage_path="./storage/"))
manager.set_storage("sqlite", SQLiteCache(storage_path="./storage/cache.db"))
manager.set_storage("redis", RedisCache(host="localhost", port=6379, db=0))
manager.set_storage("mysql", MySQLCache(connection_string="mysql://root:password@localhost:3306/test", table="cache"))
manager.set_storage("postgresql", PostgreSQLCache(connection_string="postgresql://postgres:password@localhost:5432/test", table="cache"))

# Test file cache
print("Testing file cache:")
manager.get_storage("local").set("test", "File cache test")
print(manager.get_storage("local").get("test"))
print(manager.get_storage("local").exists("test"))
manager.get_storage("local").delete("test")
print(manager.get_storage("local").exists("test"))

# Test SQLite cache
print("\nTesting SQLite cache:")
manager.get_storage("sqlite").set("test", "SQLite cache test")
print(manager.get_storage("sqlite").get("test"))
print(manager.get_storage("sqlite").exists("test"))
manager.get_storage("sqlite").delete("test")
print(manager.get_storage("sqlite").exists("test"))

# Test Redis cache
print("\nTesting Redis cache:")
manager.get_storage("redis").set("test", "Redis cache test")
print(manager.get_storage("redis").get("test"))
print(manager.get_storage("redis").exists("test"))
manager.get_storage("redis").delete("test")
print(manager.get_storage("redis").exists("test"))

# Test MySQL cache
print("\nTesting MySQL cache:")
manager.get_storage("mysql").set("test", "MySQL cache test")
print(manager.get_storage("mysql").get("test"))
print(manager.get_storage("mysql").exists("test"))
manager.get_storage("mysql").delete("test")
print(manager.get_storage("mysql").exists("test"))

# Test PostgreSQL cache
print("\nTesting PostgreSQL cache:")
manager.get_storage("postgresql").set("test", "PostgreSQL cache test")
print(manager.get_storage("postgresql").get("test"))
print(manager.get_storage("postgresql").exists("test"))
manager.get_storage("postgresql").delete("test")
print(manager.get_storage("postgresql").exists("test"))

# Test expiration time
print("\nTesting expiration time:")
manager.get_storage("local").set("expire_test", "Expiration test", expire=5)
print(manager.get_storage("local").get("expire_test"))
import time
print("Waiting for 6 seconds...")
time.sleep(6)
print(manager.get_storage("local").get("expire_test"))

# Test default storage
print("\nTesting default storage:")
manager.set("default_test", "Default storage test")
print(manager.get("default_test"))
print(manager.exists("default_test"))
manager.delete("default_test")
print(manager.exists("default_test"))

Contributing

Contributions are welcome, whether it's code contributions, bug reports, or suggestions for improvements. Please check our contribution guidelines for more information.

License

efcCache is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for efcCache 0.0.4

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

Source distribution (sdist)

Source distribution for efcCache 0.0.4
File Size Uploaded Provenance
efccache-0.0.4.tar.gz 6.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for efcCache 0.0.4
File Interpreter ABI Platform
efcCache-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / efccache-0.0.4.tar.gz

Download URL efccache-0.0.4.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8d5cead811a06d2b6d32d7540e385bff340cec0370898a38d37ac1bfab4c9f4f
BLAKE2b-256 checksum
How to use checksums
1ec23d625eb9e6af0bb6c04db0379a67cd9776bb271315ddbb1e59b79f72b2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / efcCache-0.0.4-py3-none-any.whl

Download URL efcCache-0.0.4-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82ff4bd4996f7f9e2b871fa4d1b1eb0925733981e6387a4686dfee27240b0e7c
BLAKE2b-256 checksum
How to use checksums
baef0a2040035ea682410d68ff5c536c738fcb406dc69722d37a7263b7bd16bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for efcCache 0.0.4

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