lavoiesl / doctrine-cache-provider
该软件包已被废弃,不再维护。未建议替代包。
库,用于添加Doctrine Provider,允许Doctrine Cache连接到数据库。
v1.1
2014-04-08 00:14 UTC
Requires
Suggests
- lavoiesl/doctrine-cache-detector: Library to detect which Doctrine Cache system is available and determine the best to use.
This package is not auto-updated.
Last update: 2022-07-18 08:52:00 UTC
README
库,用于添加Doctrine Provider,允许Doctrine Cache连接到数据库。
这可以用于一个穷人的分布式缓存系统。
使用Doctrine DBAL和序列化
。
见http://doctrine-dbal.readthedocs.org/en/latest/reference/configuration.html
用法
<?php use Lavoiesl\Doctrine\CacheProvider\DoctrineCache; // Doctrine config $config = new \Doctrine\DBAL\Configuration(); $connectionParams = array( 'dbname' => 'mydb', 'user' => 'user', 'password' => 'secret', 'host' => 'localhost', 'driver' => 'pdo_mysql', ); $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); // DoctrineCache config $fields = array( 'id' => 'name', 'data' => 'data', 'expiration' => 'expiration', ); $cache = new DoctrineCache($conn, 'my_table_cache', $fields); $cache->save('key', $value, $ttl); $cache->fetch('key'); ?>
配置
您需要一个正常工作的数据库和适当的表。包含一个模式工具。
<?php use Lavoiesl\Doctrine\CacheProvider\CacheSchema; CacheSchema::createTable($connection, 'my_table_cache', $fields); ?>
运行测试
要运行MySQL测试,您需要一个具有用户test
和密码test
的test
数据库。
待办事项
包括其他Doctrine驱动程序测试