{"id":15089003,"url":"https://github.com/yashgupta-dev/caching-performance-optimization","last_synced_at":"2026-04-04T06:38:44.974Z","repository":{"id":249514828,"uuid":"831726744","full_name":"yashgupta-dev/caching-performance-optimization","owner":"yashgupta-dev","description":"caching-performance-optimization","archived":false,"fork":false,"pushed_at":"2024-07-21T15:23:35.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-20T02:35:38.459Z","etag":null,"topics":["cache","composer","php","simple-cache"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/code-corner/performance-cache","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yashgupta-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-21T12:58:38.000Z","updated_at":"2024-07-21T13:47:56.000Z","dependencies_parsed_at":"2025-02-20T02:43:33.723Z","dependency_job_id":null,"html_url":"https://github.com/yashgupta-dev/caching-performance-optimization","commit_stats":null,"previous_names":["yashgupta-dev/caching-performance-optimization"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashgupta-dev%2Fcaching-performance-optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashgupta-dev%2Fcaching-performance-optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashgupta-dev%2Fcaching-performance-optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashgupta-dev%2Fcaching-performance-optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yashgupta-dev","download_url":"https://codeload.github.com/yashgupta-dev/caching-performance-optimization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243358068,"owners_count":20277989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","composer","php","simple-cache"],"created_at":"2024-09-25T08:38:36.784Z","updated_at":"2025-12-28T08:06:39.946Z","avatar_url":"https://github.com/yashgupta-dev.png","language":"PHP","readme":"# PerformanceCache Package\n\nThe **PerformanceCache** package provides a robust caching solution that adheres to the PSR-16 (Simple Cache) interface, allowing developers to efficiently manage caching operations in PHP applications.\n\n## Installation\n\nYou can install the PerformanceCache package via Composer. Run the following command in your terminal:\n\n```bash\ncomposer require codecorners/performance-cache\n```\n\n## Usage\n\n### Initializing the Cache\n\nTo start using the cache, initialize an instance of `Cache`. By default, it uses `FileCacheHandler` for file-based caching:\n\n```php\nuse CodeCorner\\PerformanceCache\\Cache;\nuse CodeCorner\\PerformanceCache\\FileCacheHandler;\n\n// Initialize cache with default handler (FileCacheHandler)\n$cache = new Cache();\n```\n\nYou can optionally pass a custom cache handler to the constructor:\n\n```php\nuse CodeCorner\\PerformanceCache\\Cache;\nuse App\\CustomCacheHandler; // Replace with your custom cache handler\n\n// Initialize cache with custom handler\n$customHandler = new CustomCacheHandler();\n$cache = new Cache($customHandler);\n```\n\n### Basic Cache Operations\n\n#### Setting a Cache Value\n\n```php\n$key = 'my_key';\n$value = 'my_value';\n$ttl = 3600; // Optional TTL (time-to-live) in seconds\n\nif ($cache-\u003eset($key, $value, $ttl)) {\n    echo \"Value successfully cached!\\n\";\n} else {\n    echo \"Failed to cache the value.\\n\";\n}\n```\n\n#### Getting a Cached Value\n\n```php\n$key = 'my_key';\n$defaultValue = 'default_value'; // Optional default value if key not found\n\n$cachedValue = $cache-\u003eget($key, $defaultValue);\n\necho \"Cached Value: $cachedValue\\n\";\n```\n\n#### Deleting a Cached Value\n\n```php\n$key = 'my_key';\n\nif ($cache-\u003edelete($key)) {\n    echo \"Cache entry successfully deleted!\\n\";\n} else {\n    echo \"Failed to delete the cache entry.\\n\";\n}\n```\n\n#### Clearing All Cached Values\n\n```php\nif ($cache-\u003eclear()) {\n    echo \"Cache cleared successfully!\\n\";\n} else {\n    echo \"Failed to clear the cache.\\n\";\n}\n```\n\n#### Working with Multiple Cache Entries\n\n##### Getting Multiple Cache Entries\n\n```php\n$keys = ['key1', 'key2', 'key3'];\n$defaultValue = 'default_value'; // Optional default value if any key is not found\n\n$cachedValues = $cache-\u003egetMultiple($keys, $defaultValue);\n\nforeach ($cachedValues as $key =\u003e $value) {\n    echo \"Key: $key, Value: $value\\n\";\n}\n```\n\n##### Setting Multiple Cache Entries\n\n```php\n$values = [\n    'key1' =\u003e 'value1',\n    'key2' =\u003e 'value2',\n    'key3' =\u003e 'value3',\n];\n$ttl = 3600; // Optional TTL for all entries\n\nif ($cache-\u003esetMultiple($values, $ttl)) {\n    echo \"Multiple values successfully cached!\\n\";\n} else {\n    echo \"Failed to cache multiple values.\\n\";\n}\n```\n\n##### Deleting Multiple Cache Entries\n\n```php\n$keysToDelete = ['key1', 'key2', 'key3'];\n\nif ($cache-\u003edeleteMultiple($keysToDelete)) {\n    echo \"Multiple cache entries deleted successfully!\\n\";\n} else {\n    echo \"Failed to delete multiple cache entries.\\n\";\n}\n```\n\n#### Checking if a Key Exists in Cache\n\n```php\n$key = 'my_key';\n\nif ($cache-\u003ehas($key)) {\n    echo \"Key '$key' exists in cache.\\n\";\n} else {\n    echo \"Key '$key' does not exist in cache.\\n\";\n}\n```\n\n### Error Handling\n\nThe `Cache` class provides basic error handling for cache operations. If an operation fails (e.g., cache read, write, delete), it logs the error message using `error_log()`.\n\n## License\n\nThis package is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.\n\n## Author\n\nWritten by Yash Gupta.\n\n---\n\nReplace placeholders such as `Yash Gupta` with your actual name or preferred pseudonym. Ensure the `LICENSE` file is present in your project directory and contains the appropriate license text for distribution.\n\nThis README file provides comprehensive guidance for developers looking to integrate the **PerformanceCache** package into their PHP projects, covering installation, basic usage examples, error handling considerations, and licensing information. Adjust the examples and instructions as per your specific implementation and documentation style.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashgupta-dev%2Fcaching-performance-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyashgupta-dev%2Fcaching-performance-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashgupta-dev%2Fcaching-performance-optimization/lists"}