# fluent-cart/1.6.4/app/Services/Cache.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.4. 59 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Services/Cache.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/app/Services/Cache.php
- Modified: 2026-03-13T16:10:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Services/Cache.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Services;

use FluentCart\App\App;

class Cache
{

    public static function get($key, $callback = false, $expire = 3600)
    {
        $key = static::getKey($key);

        $value = wp_cache_get($key, static::getGroupName());

        if ($value !== false) {
            return $value;
        }

        if ($callback) {
            $value = $callback();
            if ($value !== null) {
                static::set($key, $value, $expire);
            }
        }

        return $value;
    }

    public static function forget($key): bool
    {
        return wp_cache_delete(static::getKey($key), static::getGroupName());
    }

    public static function set($key, $value, $expire = 3600): bool
    {
        return wp_cache_set(static::getKey($key), $value, static::getGroupName(), $expire);
    }

    public static function update($key, $value, $expire = 3600): bool
    {
        return static::set(static::getKey($key), $value, $expire);
    }

    private static function getKey(string $key): string
    {
        return static::getKeyPrefix() . '_' . $key;
    }

    private static function getKeyPrefix()
    {
        return App::config()->get('slug');
    }

    private static function getGroupName(): string
    {
        return 'fluent-cart';
    }
}
```
