2014-09-18 118 views
4

我開始在我的項目(php-redis)上使用Redis。是Symfony2的項目,我發現:清除存儲在Redis中的Doctrine緩存

https://github.com/snc/SncRedisBundle

我按照安裝過程和我配置:

  • 有些客戶不存-SQL數據和緩存
  • 會話存儲
  • 學說metada,結果和查詢緩存

我crea在一個捆綁中的新實體,我失敗了,因爲我在yml創建它,我有所有其他的註釋系統,所以我刪除yml格式並創建註釋。

我在註解類(例如更改表名)上進行的每個更改都不會影響架構或數據庫,即使我重新創建數據庫或嘗試執行緩存:使用所有選項清除。

如果我只是評論redis原則配置行,它的作品,我可以看到架構上的變化。

我也許忘了一些東西,或者我真的找不到如何清理該教條redis緩存。

¿我必須手動清理redis客戶端上用於緩存的任何位置?

下面是配置:

#Snc Redis Bundle 
snc_redis: 
    clients: 
    d2a: 
     type: phpredis 
     alias: d2a 
     dsn: redis://localhost/1 
    cache: 
     type: phpredis 
     alias: cache 
     dsn: redis://localhost 
     logging: true 
    session: 
    client: d2a 
    prefix: redis_session 
    doctrine: 
    metadata_cache: 
     client: cache 
     entity_manager: default   # the name of your entity_manager connection 
     document_manager: default  # the name of your document_manager connection 
    result_cache: 
     client: cache 
     entity_manager: [default, read] # you may specify multiple entity_managers 
    query_cache: 
     client: cache 
     entity_manager: default 
+0

你試過完全刪除實體,並與註釋,而不是陽明重建呢? – andy 2014-09-18 21:17:14

+0

是的,我試過了,是對我的問題的解釋 – ruudy 2014-09-20 08:34:43

回答

1

最簡單的方法,但不是最好的一個是沖洗Redis的教義緩存分貝。運行

php app/console redis:flushdb --client=cache 

(未測試!)另一種方式是建立教義元數據緩存在教義配置http://symfony.com/doc/current/reference/configuration/doctrine.html#caching-drivers

orm: 
    entity_managers: 
     # A collection of different named entity managers (e.g. some_em, another_em) 
     some_em: 
      metadata_cache_driver: 
       type:     array # Required 
       host:     ~ 
       port:     ~ 
       instance_class:  ~ 
       class:    ~