| @@ 334-354 (lines=21) @@ | ||
| 331 | * |
|
| 332 | * @return mixed |
|
| 333 | */ |
|
| 334 | public static function get_group( $id, $group = '', $cache_type = 'persistent' ) { |
|
| 335 | $cached_data = false; |
|
| 336 | ||
| 337 | // Bailout. |
|
| 338 | if ( |
|
| 339 | // We can disable cache by setting GIVE_CACHE false. |
|
| 340 | ( defined( 'GIVE_CACHE' ) && ! GIVE_CACHE ) || |
|
| 341 | empty( $id ) || |
|
| 342 | empty( $cache_type ) |
|
| 343 | ) { |
|
| 344 | return $cached_data; |
|
| 345 | } |
|
| 346 | ||
| 347 | switch ( $cache_type ) { |
|
| 348 | case 'persistent': |
|
| 349 | $cached_data = wp_cache_get( $id, $group ); |
|
| 350 | break; |
|
| 351 | } |
|
| 352 | ||
| 353 | return $cached_data; |
|
| 354 | } |
|
| 355 | ||
| 356 | /** |
|
| 357 | * Cache small chunks inside group |
|
| @@ 370-390 (lines=21) @@ | ||
| 367 | * |
|
| 368 | * @return bool |
|
| 369 | */ |
|
| 370 | public static function set_group( $id, $data, $group = '', $expire = 0, $cache_type = 'persistent' ) { |
|
| 371 | $status = false; |
|
| 372 | ||
| 373 | // Bailout. |
|
| 374 | if ( |
|
| 375 | // We can disable cache by setting GIVE_CACHE false. |
|
| 376 | ( defined( 'GIVE_CACHE' ) && ! GIVE_CACHE ) || |
|
| 377 | empty( $id ) || |
|
| 378 | empty( $cache_type ) |
|
| 379 | ) { |
|
| 380 | return $status; |
|
| 381 | } |
|
| 382 | ||
| 383 | switch ( $cache_type ) { |
|
| 384 | case 'persistent': |
|
| 385 | $status = wp_cache_set( $id, $data, $group, $expire ); |
|
| 386 | break; |
|
| 387 | } |
|
| 388 | ||
| 389 | return $status; |
|
| 390 | } |
|
| 391 | ||
| 392 | /** |
|
| 393 | * Delete group cache |
|
| @@ 405-425 (lines=21) @@ | ||
| 402 | * |
|
| 403 | * @return bool |
|
| 404 | */ |
|
| 405 | public static function delete_group( $id, $group = '', $expire = 0, $cache_type = 'persistent' ) { |
|
| 406 | $status = false; |
|
| 407 | ||
| 408 | // Bailout. |
|
| 409 | if ( |
|
| 410 | // We can disable cache by setting GIVE_CACHE false. |
|
| 411 | ( defined( 'GIVE_CACHE' ) && ! GIVE_CACHE ) || |
|
| 412 | empty( $id ) || |
|
| 413 | empty( $cache_type ) |
|
| 414 | ) { |
|
| 415 | return $status; |
|
| 416 | } |
|
| 417 | ||
| 418 | switch ( $cache_type ) { |
|
| 419 | case 'persistent': |
|
| 420 | $status = wp_cache_delete( $id, $group, $expire ); |
|
| 421 | break; |
|
| 422 | } |
|
| 423 | ||
| 424 | return $status; |
|
| 425 | } |
|
| 426 | } |
|
| 427 | ||
| 428 | // Initialize |
|