{"id":32355,"date":"2015-01-06T15:56:23","date_gmt":"2015-01-06T15:56:23","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/voce-group-keys\/"},"modified":"2015-02-03T21:13:35","modified_gmt":"2015-02-03T21:13:35","slug":"voce-group-keys","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/voce-group-keys\/","author":10952562,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.1","stable_tag":"1.0.1","tested":"4.0.38","requires":"2.8","requires_php":"","requires_plugins":"","header_name":"Voce Group Keys","header_author":"banderon","header_description":"","assets_banners_color":"","last_updated":"2015-02-03 21:13:35","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":0,"downloads":990,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[146,7486,18914],"plugin_category":[52],"plugin_contributors":[129980],"plugin_business_model":[],"class_list":["post-32355","plugin","type-plugin","status-publish","hentry","plugin_tags-cache","plugin_tags-group","plugin_tags-keys","plugin_category-performance","plugin_contributors-banderon","plugin_committers-banderon"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/voce-group-keys.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Gives functions to use to generate strings to use as keys for caching. Keys are generated based on a passed in name and\nzero or more groups. Providing the same name and groups will return the same key until the entire cache is cleared\nor the cache for a specific group name is cleared.<\/p>\n\n<h3>Usage<\/h3>\n\n<p>$key: STRING\n$groups: STRING|ARRAY<\/p>\n\n<pre><code>&lt;?php\nif ( class_exists( 'Voce_Group_Keys' ) ) {\n\n    \/\/ Get a key for $key that is in the $groups group(s)\n    voce_get_cache_key( $key, $groups );\n\n    \/\/ Clear the keys for $groups\n    \/\/ If multiple groups are specified, keys in any of the specified groups will be cleared\n    voce_clear_group_cache( $groups );\n\n    \/\/ Clear all keys\n    voce_clear_all_group_cache();\n}\n<\/code><\/pre>\n\n<h4>Example 1<\/h4>\n\n<pre><code>&lt;?php\nif ( class_exists( 'Voce_Group_Keys' ) ) {\n\n    \/\/ Get a key without a group\n    echo voce_get_cache_key( 'data' );  \/\/ data_4942b011eb\n\n    \/\/ Get keys in a single group\n    echo voce_get_cache_key( 'data', 'people' );  \/\/ data_9915443f5c\n    echo voce_get_cache_key( 'more-data', 'people' );  \/\/ more-data_9915443f5c\n\n    \/\/ The same key will be returned\n    echo voce_get_cache_key( 'data', 'people' );  \/\/ data_9915443f5c\n\n    \/\/ Clear keys in the 'people' group\n    voce_clear_group_cache( 'people' );\n\n    \/\/ After clearing keys, a new key is returned for keys using that group\n    echo voce_get_cache_key( 'data', 'people' );  \/\/ data_77j18e728\n    echo voce_get_cache_key( 'data' );  \/\/ data_4942b011eb\n\n}\n<\/code><\/pre>\n\n<h4>Example 2<\/h4>\n\n<pre><code>&lt;?php\nif ( class_exists( 'Voce_Group_Keys' ) ) {\n\n    \/\/ Set transients using multiple groups\n    echo voce_get_cache_key( 'user-data', 'users' );  \/\/ user-data_9915443f5c\n    echo voce_get_cache_key( 'post-data', 'posts' );  \/\/ post-data_85fb002156\n    echo voce_get_cache_key( 'user-post-data', array( 'posts', 'users' ) );  \/\/ user-post-data_4aee2c2c89\n\n    \/\/ Clear any keys using the 'posts' group\n    voce_clear_group_cache( 'posts' );\n\n    \/\/ New keys returned for anything in the 'posts' group\n    echo voce_get_cache_key( 'user-data', 'users' );  \/\/ user-data_9915443f5c\n    echo voce_get_cache_key( 'post-data', 'posts' );  \/\/ post-data_820dd0dfb0\n    echo voce_get_cache_key( 'user-post-data', array( 'posts', 'users' ) );  \/\/ user-post-data_b7ac93f802\n\n    \/\/ The order of groups is irrelevant\n    echo voce_get_cache_key( 'user-post-data', array( 'users', 'posts' ) );  \/\/ user-post-data_b7ac93f802\n\n    \/\/ Clear any keys in either the 'users' or 'posts' groups\n    voce_clear_group_cache( array( 'users', 'posts' ) );\n\n    \/\/ Clear all keys\n    voce_clear_all_group_cache();\n}\n<\/code><\/pre>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>voce-group-keys.php<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Use the plugin's functions where necessary in your code, making sure to check if the plugin is enabled<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>1.0.1<\/h4>\n\n<p>*Bug fix: added slight delay when saving new keys to avoid collisions<\/p>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release<\/li>\n<\/ul>","raw_excerpt":"Create string keys for caching based off of specified groups, allowing clearing keys based on the groups to which they belong.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/32355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=32355"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/banderon"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=32355"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=32355"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=32355"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=32355"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=32355"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=32355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}