<p>You put your Redis connection information in your <code>craft/config/rediscache.php</code> config file.  You can see the default <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/etc/config/defaults/rediscache.php" rel="nofollow">here</a>, and your file will override any matching set keys.</p>

<p>From there you can use <code>craft()-&gt;cache-&gt;set()</code>, <code>craft()-&gt;cache-&gt;get()</code> and any other cache methods on Yii's <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/framework/caching/CCache.php" rel="nofollow">CCache</a> class.</p>

CC BY-SA 3.0
2015-11-29T06:25:22.923Z
I should've known...! Don't know what I'd do without you sometimes. Thanks, Brad!
taylor
CC BY-SA 3.0
2015-11-29T06:03:45.890Z
2015-11-29T07:12:58.937Z
2015-11-29T07:12:58.937Z
Brad Bell
<p>How would I access the available <code>RedisCache</code> class and it's properties/methods in PHP/plugins? (<a href="https://buildwithcraft.com/classreference/etc/cache/RedisCache" rel="nofollow">https://buildwithcraft.com/classreference/etc/cache/RedisCache</a>)</p>

<p>I'm just starting to learn Redis and can't seem to find more information about how to start using the available class. I have set <a href="http://buildwithcraft.com/docs/config-settings#cacheMethod" rel="nofollow">cacheMethod</a> to <code>redis</code>, and created a <code>rediscache.php</code> file in <code>craft/config/</code>.</p>

<p>I want to explore connecting to db, inserting my own keys/values and retrieving data for my other plugins, but can't seem to find the right path path. I tried things like:</p>

<pre><code>echo craft()-&gt;redisCache-&gt;hostname; 
</code></pre>

<p>But that returns <code>CExeption</code> errors. What am I missing?</p>

<plugin-development><cache><php>
Using RedisCache Class & Methods
# Using RedisCache Class & Methods

(Asked by: username_0 on 2015-11-29)

How would I access the available RedisCache class and it's properties/methods in PHP/plugins? (https://buildwithcraft.com/classreference/etc/cache/RedisCache)
I'm just starting to learn Redis and can't seem to find more information about how to start using the available class. I have set cacheMethod to redis, and created a rediscache.php file in craft/config/.
I want to explore connecting to db, inserting my own keys/values and retrieving data for my other plugins, but can't seem to find the right path path. I tried things like:
echo craft()->redisCache->hostname; 

But that returns CExeption errors. What am I missing?

**Tags:** plugin-development, cache, php

---

## 1 answers

### Answer by username_1 on 2015-11-29. Score: 1 | Accepted answer

You put your Redis connection information in your `craft/config/rediscache.php` config file. You can see the default [here](https://github.com/pixelandtonic/Craft-Release/blob/master/app/etc/config/defaults/rediscache.php), and your file will override any matching set keys.

From there you can use `craft()->cache->set()`, `craft()->cache->get()` and any other cache methods on Yii's [CCache](https://github.com/pixelandtonic/Craft-Release/blob/master/app/framework/caching/CCache.php) class.

> **Comments:**
> **username_0**: I should've known...! Don't know what I'd do without you sometimes. Thanks, Brad!  

---

