efcCache


NameefcCache JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/duolabmeng6/efcCache
SummaryA file storage management package supporting various providers like S3, OSS, and Qiniu.
upload_time2024-09-23 19:08:33
maintainerNone
docs_urlNone
authorduolabmeng6
requires_python>=3.6
licenseNone
keywords efccache
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [English](README.md)
[简体中文](README_ZH.md)

# 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:

```bash
pip install efcCache
```

## Quick Start

Here's a simple example of using efcCache:

```python
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:
```python
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](CONTRIBUTING.md) for more information.

## License

efcCache is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/duolabmeng6/efcCache",
    "name": "efcCache",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "efcCache",
    "author": "duolabmeng6",
    "author_email": "1715109585@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/1e/c2/3d625eb9e6af0bb6c04db0379a67cd9776bb271315ddbb1e59b79f72b2fb/efccache-0.0.4.tar.gz",
    "platform": null,
    "description": "[English](README.md)\n[\u7b80\u4f53\u4e2d\u6587](README_ZH.md)\n\n# efcCache\n\nefcCache is a general-purpose cache library that supports multiple storage backends, including:\n\n- Local file\n- SQLite\n- MySQL\n- PostgreSQL\n- Redis\n\n## Installation\n\nInstall efcCache using pip:\n\n```bash\npip install efcCache\n```\n\n## Quick Start\n\nHere's a simple example of using efcCache:\n\n```python\nimport efcCache\nfrom efcCache.providers.FileCache import FileCache\n\n# Create a cache manager\ncacheManager = efcCache.CacheManager(default_storage=\"local\")\n\n# Set up storage backend\ncacheManager.set_storage(\"local\", FileCache(storage_path=\"./storage/\"))\n\n# Use the cache class\nprint(\"Testing file cache:\")\ncacheManager.set(\"test\", \"File cache test\")\nprint(cacheManager.get(\"test\"))\nprint(cacheManager.exists(\"test\"))\ncacheManager.delete(\"test\")\nprint(cacheManager.exists(\"test\"))\n```\n\nImporting other cache providers:\n```python\nimport efcCache\nfrom efcCache.providers.FileCache import FileCache\nfrom efcCache.providers.SQLiteCache import SQLiteCache\nfrom efcCache.providers.RedisCache import RedisCache\nfrom efcCache.providers.MySQLCache import MySQLCache\nfrom efcCache.providers.PostgreSQLCache import PostgreSQLCache\n\n# Create a cache manager\nmanager = efcCache.CacheManager(default_storage=\"local\")\n\n# Set up storage backends\nmanager.set_storage(\"local\", FileCache(storage_path=\"./storage/\"))\nmanager.set_storage(\"sqlite\", SQLiteCache(storage_path=\"./storage/cache.db\"))\nmanager.set_storage(\"redis\", RedisCache(host=\"localhost\", port=6379, db=0))\nmanager.set_storage(\"mysql\", MySQLCache(connection_string=\"mysql://root:password@localhost:3306/test\", table=\"cache\"))\nmanager.set_storage(\"postgresql\", PostgreSQLCache(connection_string=\"postgresql://postgres:password@localhost:5432/test\", table=\"cache\"))\n\n# Test file cache\nprint(\"Testing file cache:\")\nmanager.get_storage(\"local\").set(\"test\", \"File cache test\")\nprint(manager.get_storage(\"local\").get(\"test\"))\nprint(manager.get_storage(\"local\").exists(\"test\"))\nmanager.get_storage(\"local\").delete(\"test\")\nprint(manager.get_storage(\"local\").exists(\"test\"))\n\n# Test SQLite cache\nprint(\"\\nTesting SQLite cache:\")\nmanager.get_storage(\"sqlite\").set(\"test\", \"SQLite cache test\")\nprint(manager.get_storage(\"sqlite\").get(\"test\"))\nprint(manager.get_storage(\"sqlite\").exists(\"test\"))\nmanager.get_storage(\"sqlite\").delete(\"test\")\nprint(manager.get_storage(\"sqlite\").exists(\"test\"))\n\n# Test Redis cache\nprint(\"\\nTesting Redis cache:\")\nmanager.get_storage(\"redis\").set(\"test\", \"Redis cache test\")\nprint(manager.get_storage(\"redis\").get(\"test\"))\nprint(manager.get_storage(\"redis\").exists(\"test\"))\nmanager.get_storage(\"redis\").delete(\"test\")\nprint(manager.get_storage(\"redis\").exists(\"test\"))\n\n# Test MySQL cache\nprint(\"\\nTesting MySQL cache:\")\nmanager.get_storage(\"mysql\").set(\"test\", \"MySQL cache test\")\nprint(manager.get_storage(\"mysql\").get(\"test\"))\nprint(manager.get_storage(\"mysql\").exists(\"test\"))\nmanager.get_storage(\"mysql\").delete(\"test\")\nprint(manager.get_storage(\"mysql\").exists(\"test\"))\n\n# Test PostgreSQL cache\nprint(\"\\nTesting PostgreSQL cache:\")\nmanager.get_storage(\"postgresql\").set(\"test\", \"PostgreSQL cache test\")\nprint(manager.get_storage(\"postgresql\").get(\"test\"))\nprint(manager.get_storage(\"postgresql\").exists(\"test\"))\nmanager.get_storage(\"postgresql\").delete(\"test\")\nprint(manager.get_storage(\"postgresql\").exists(\"test\"))\n\n# Test expiration time\nprint(\"\\nTesting expiration time:\")\nmanager.get_storage(\"local\").set(\"expire_test\", \"Expiration test\", expire=5)\nprint(manager.get_storage(\"local\").get(\"expire_test\"))\nimport time\nprint(\"Waiting for 6 seconds...\")\ntime.sleep(6)\nprint(manager.get_storage(\"local\").get(\"expire_test\"))\n\n# Test default storage\nprint(\"\\nTesting default storage:\")\nmanager.set(\"default_test\", \"Default storage test\")\nprint(manager.get(\"default_test\"))\nprint(manager.exists(\"default_test\"))\nmanager.delete(\"default_test\")\nprint(manager.exists(\"default_test\"))\n```\n\n## Contributing\n\nContributions are welcome, whether it's code contributions, bug reports, or suggestions for improvements. Please check our [contribution guidelines](CONTRIBUTING.md) for more information.\n\n## License\n\nefcCache is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A file storage management package supporting various providers like S3, OSS, and Qiniu.",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/duolabmeng6/efcCache"
    },
    "split_keywords": [
        "efccache"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "baef0a2040035ea682410d68ff5c536c738fcb406dc69722d37a7263b7bd16bd",
                "md5": "53a785cf149818c3e58cf38f1e987460",
                "sha256": "82ff4bd4996f7f9e2b871fa4d1b1eb0925733981e6387a4686dfee27240b0e7c"
            },
            "downloads": -1,
            "filename": "efcCache-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "53a785cf149818c3e58cf38f1e987460",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7571,
            "upload_time": "2024-09-23T19:08:33",
            "upload_time_iso_8601": "2024-09-23T19:08:33.060839Z",
            "url": "https://files.pythonhosted.org/packages/ba/ef/0a2040035ea682410d68ff5c536c738fcb406dc69722d37a7263b7bd16bd/efcCache-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ec23d625eb9e6af0bb6c04db0379a67cd9776bb271315ddbb1e59b79f72b2fb",
                "md5": "00ca550d90b69edcfa8d855a7b9954df",
                "sha256": "8d5cead811a06d2b6d32d7540e385bff340cec0370898a38d37ac1bfab4c9f4f"
            },
            "downloads": -1,
            "filename": "efccache-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "00ca550d90b69edcfa8d855a7b9954df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6076,
            "upload_time": "2024-09-23T19:08:33",
            "upload_time_iso_8601": "2024-09-23T19:08:33.988742Z",
            "url": "https://files.pythonhosted.org/packages/1e/c2/3d625eb9e6af0bb6c04db0379a67cd9776bb271315ddbb1e59b79f72b2fb/efccache-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-23 19:08:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "duolabmeng6",
    "github_project": "efcCache",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "efccache"
}
        
Elapsed time: 4.83306s