{"id":5869,"library":"cachy","title":"Cachy","description":"Cachy provides a simple yet effective caching library for Python. It offers a powerful and thread-safe API with decorator syntax and supports various backend stores including memcached, Redis, database, file system, and in-memory dictionaries. The current stable version is 0.3.0, released in 2019.","status":"maintenance","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/sdispater/cachy","tags":["caching","cache","performance","utility"],"install":[{"cmd":"pip install cachy","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required Python interpreter versions.","package":"python","version":">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"},{"reason":"Optional, for Redis cache store.","package":"redis","optional":true},{"reason":"Optional, for Memcached cache store.","package":"python-memcached","optional":true},{"reason":"Optional, for database cache store (implicitly needed for 'database' driver).","package":"SQLAlchemy","optional":true}],"imports":[{"note":"The primary class for interacting with caching functionality.","symbol":"Cache","correct":"from cachy import Cache"}],"quickstart":{"code":"from cachy import Cache\nimport os\n\n# Configure a file-based cache store\nCache.configure({\n    'stores': {\n        'file': {\n            'driver': 'file',\n            'path': os.path.join(os.getcwd(), 'cache_data'),\n        },\n        'redis': {\n            'driver': 'redis',\n            'host': os.environ.get('REDIS_HOST', 'localhost'),\n            'password': os.environ.get('REDIS_PASSWORD'),\n            'port': int(os.environ.get('REDIS_PORT', 6379)),\n            'database': int(os.environ.get('REDIS_DB', 0)),\n        }\n    },\n    'default': 'file',\n})\n\n# Get the default cache store (file)\ncache = Cache.store()\n\n# Put an item in the cache for 10 minutes (600 seconds)\ncache.put('my_key', 'my_value', 600)\n\n# Retrieve an item from the cache\nvalue = cache.get('my_key')\nprint(f\"Retrieved value: {value}\")\n\n# Check if an item exists\nexists = cache.has('my_key')\nprint(f\"Key exists: {exists}\")\n\n# Get a specific store (e.g., Redis)\n# Ensure Redis is running and configured correctly via env vars or direct config.\n# try:\n#     redis_cache = Cache.store('redis')\n#     redis_cache.put('redis_key', 'redis_value', 60)\n#     print(f\"Retrieved from Redis: {redis_cache.get('redis_key')}\")\n# except Exception as e:\n#     print(f\"Could not connect to Redis: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to configure and use Cachy with a file-based store. It shows how to put, retrieve, and check for items in the cache. An example for a Redis store is also included (commented out), highlighting the need for external service configuration."},"warnings":[{"fix":"Ensure your Python environment is version 2.7+ or 3.4+.","message":"Cachy explicitly excludes Python versions 3.0 through 3.3. Attempting to use the library with these interpreter versions will result in an error due to the `requires_python` metadata.","severity":"breaking","affected_versions":"All versions"},{"fix":"Evaluate against your project's longevity and maintenance requirements. Consider alternatives if active support or newer Python version compatibility (beyond the declared `requires_python`) is critical.","message":"The library's last release was in August 2019 (v0.3.0). This indicates it is not under active development and may not receive updates for newer Python versions, security patches, or compatibility with future library ecosystems.","severity":"gotcha","affected_versions":"0.3.0 and older"},{"fix":"Install the necessary client libraries for your chosen cache store (`pip install redis` for Redis, `pip install python-memcached` for Memcached) and verify configuration parameters (host, port, credentials) are correct and accessible.","message":"When using external cache stores (e.g., Redis, Memcached), Cachy relies on separate client libraries (e.g., `redis`, `python-memcached`). These must be installed manually and configured correctly in Cachy's global configuration. Misconfiguration or missing dependencies will lead to runtime errors or silently failed caching operations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Design your application to initialize Cachy's configuration once at startup. If dynamic configuration is needed, consider if Cachy's global approach aligns with your architecture or if a more isolated caching solution is required.","message":"Cachy uses a global configuration (`Cache.configure`). If your application needs different cache configurations for various parts or threads, managing this global state can become complex and lead to unexpected interactions. Ensure careful handling of configuration updates in multi-threaded or multi-component applications.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}