mactronique/phpcache-bundle

此包已被废弃且不再维护。作者建议使用 doctrine/doctrine-cache-bundle 包。

phpcache 库的包装器

1.0.1 2015-09-24 12:56 UTC

This package is auto-updated.

Last update: 2022-02-01 12:49:40 UTC


README

Dependency Status Latest Stable Version Latest Unstable Version License

安装

php composer.phar require mactronique/phpcache-bundle "~1.0"

配置

注册包

在你的 app/AppKernel.php 中添加

new Mactronique\Bundle\PhpCacheBundle\MactroniquePhpCacheBundle(),

编写语义配置

在你的 app/config/config.yml 中添加

mactronique_php_cache:
    drivers:
        -
            name: xcache
        -
            name: redis
            options:
                    host: 127.0.0.1
                    port: 6379
                    password: ''
                    database: 1
                    timeout: 1
		-
			name: memcached
			options:
				-
					server: 127.0.0.1
					port: 11211
					sharing: 100
        -
            name: "null"

使用

在控制器中

// Set value into key for 30 seconds
$this->get('mactronique_cache.phpcache')->set('key', 'value', 30);

// Set value into key
$this->get('mactronique_cache.phpcache')->set('key', 'value');

//get key
$this->get('mactronique_cache.phpcache')->get('key');

//check if key exists
$this->get('mactronique_cache.phpcache')->exists('key');

//remove key
$this->get('mactronique_cache.phpcache')->remove('key');

贡献

请将主仓库进行分支操作,并提交带有你修改的 pull request。

提前感谢!