{"id":15509065,"url":"https://github.com/devuri/ob-cache","last_synced_at":"2025-03-28T18:46:55.629Z","repository":{"id":212978826,"uuid":"732725039","full_name":"devuri/ob-cache","owner":"devuri","description":"The ObCache class is a versatile and easy-to-use PHP class designed for caching in WordPress environments.","archived":false,"fork":false,"pushed_at":"2023-12-17T17:41:30.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T22:07:14.398Z","etag":null,"topics":["packagist","php","php-library"],"latest_commit_sha":null,"homepage":"","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/devuri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-17T16:23:48.000Z","updated_at":"2024-07-22T04:34:48.000Z","dependencies_parsed_at":"2023-12-17T18:43:08.770Z","dependency_job_id":null,"html_url":"https://github.com/devuri/ob-cache","commit_stats":null,"previous_names":["devuri/ob-cache"],"tags_count":1,"template":false,"template_full_name":"devuri/dot-access","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Fob-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Fob-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Fob-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devuri%2Fob-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devuri","download_url":"https://codeload.github.com/devuri/ob-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246083361,"owners_count":20720955,"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":["packagist","php","php-library"],"created_at":"2024-10-02T09:41:17.441Z","updated_at":"2025-03-28T18:46:55.611Z","avatar_url":"https://github.com/devuri.png","language":"PHP","readme":"# README for the `ObCache` Class\n\n## Overview\nThe `ObCache` class is a versatile and easy-to-use PHP class designed for caching in WordPress environments. It provides functionality to manage caching operations with ease, supporting operations such as setting, getting, and removing cached data. This class is particularly useful in scenarios where data retrieval from a cache is preferred over repeatedly querying a database or performing complex computations.\n\n## Features\n- **Flexible Caching Control**: Control whether caching is enabled or disabled.\n- **Easy Initialization**: Instantiation via a constructor or a static `init` method.\n- **Data Storage and Retrieval**: Methods for setting and retrieving cached data.\n- **Cache Removal**: Functionality to remove specific cache entries.\n\n## Usage\n\n### Instantiation\nDirectly via constructor:\n  ```php\n  $cache = new ObCache();\n  ```\nUsing the static `init` method:\n  ```php\n  $cache = ObCache::init();\n  ```\n\n### Setting Cache Mode\nEnable or disable caching:\n  ```php\n  $cache-\u003eset_cache_allowed(true); // Enable caching\n  $cache-\u003eset_cache_allowed(false); // Disable caching\n  ```\n\n### Setting Data in Cache\nUse the `set` method to cache data:\n  ```php\n  $cache-\u003eset('cache_key', function() {\n      // Data generation logic\n      return $data;\n  }, 3600); // 3600 seconds expiration\n  ```\n\n### Retrieving Data from Cache\nUse the `get` method to retrieve or generate and cache data:\n  ```php\n  $data = $cache-\u003eget('cache_key', function() {\n      // Data generation logic\n      return $data;\n  }, 3600);\n  ```\n\n### Removing Data from Cache\nUse the `forget` method to remove data from the cache:\n  ```php\n  $cache-\u003eforget('cache_key');\n  ```\n\n## Integration with WordPress\nThis class utilizes WordPress caching functions (`wp_cache_set`, `wp_cache_get`, `wp_cache_delete`) and is designed to work within a WordPress environment.\n\n## Notes\n- The class uses a protected constant `OBC_CACHE_GROUP` to define a cache group called `evp_cached` for better organization and management of cached items.\n- Cache mode status can be checked using `is_cache_allowed()` method.\n- When caching is disabled, the `set` and `get` methods directly handle data without caching.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevuri%2Fob-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevuri%2Fob-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevuri%2Fob-cache/lists"}