PHP Caching
SQLite Cache (Default)
Section titled “SQLite Cache (Default)”use FlagsGG\Client;use FlagsGG\Cache\SQLiteCache;
$client = new Client();
// Custom path$cache = new SQLiteCache('/path/to/cache.db');$client = new Client($cache);Redis Cache
Section titled “Redis Cache”For distributed applications or when you need shared cache across multiple servers:
use FlagsGG\Client;use FlagsGG\Cache\RedisCache;
// Create and connect$redisCache = new RedisCache();$redisCache->connect( host: '127.0.0.1', port: 6379, password: 'your-password', // optional database: 0);
$client = new Client($redisCache);Using an Existing Redis Instance
Section titled “Using an Existing Redis Instance”$redis = new Redis();$redis->connect('127.0.0.1', 6379);
$redisCache = new RedisCache($redis, 'my_app:'); // optional key prefix$client = new Client($redisCache);Redis is useful when:
- Multiple application instances need to share flag state
- You already have Redis in your infrastructure
- You want faster reads than SQLite
Cache Comparison
Section titled “Cache Comparison”| Feature | SQLite | Redis |
|---|---|---|
| Persistent | Yes | Yes |
| Shared across instances | No | Yes |
| Requires extension | PDO | Redis |
| Setup complexity | None | Moderate |