This is an outdated version of the Manual. Visit the NEW Manual


There are two caching mechanisms in RedBeanPHP, the Query Cache and the Bean Cache. I recommend to use the Query Cache, the Bean Cache is a plugin and it makes RedBeanPHP somewhat more complex to use.

Query Cache

In RedBeanPHP 3.4 you can use a very easy-to-use caching system: the Query Writer Cache. This caching mechanism will return the same result set for identical query-value pairs. The cache gets automatically flushed everytime something other than a select query is fired (i.e. an INSERT or DELETE). This means that this is a relatively safe cache to use. Issue the following statement to activate the Query Writer Cache:

::useWriterCache(true); (3.5.1+)


Bean Cache

RedBeanPHP offers a Bean Cache. The bean cache can be configured like this:

= new RedBean_Plugin_Cache($t->getWriter());

To allow the facade to use the cache (note that $t is a toolbox instance RedBean_ToolBox):

R::$toolbox//obtain old toolbox
R::configureFacadeWithToolbox(new RedBean_ToolBox(

To flush cache:


You can also choose to flush cached beans of a given type:



RedBeanPHP Easy ORM for PHP © 2019 Gabor de Mooij and the RedBeanPHP community - Licensed New BSD/GPLv2