# Trying to great MemCached like a SESSION array

**URL:** <https://www.ruby-forum.com/t/trying-to-great-memcached-like-a-session-array/104441>\
**Category:** Rails\
**Created:** [May 18, 2007, 12:29am UTC](https://www.ruby-forum.com/t/trying-to-great-memcached-like-a-session-array/104441 "2007-05-18T00:29:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/57b2e6/32.png) [@eddy](https://www.ruby-forum.com/u/eddy)\
**Post date:** [May 18, 2007, 12:29am UTC](https://www.ruby-forum.com/t/trying-to-great-memcached-like-a-session-array/104441/1 "2007-05-18T00:29:34Z")

</div>

hi. can someone help in what i’m doing wrong?

i just want to treat this CACHE as if it were a session / variable that  
was an array.

def test  
CACHE[:test] = []  
an\_array = %w{ foo bar baz}  
an\_array.each { |i| CACHE[:test] \<\< i }  
end

Now in Views, when i simply pull out of the array:  
\<% CACHE[:test].each do |i| %\>  
\<%= i %\>   
  
\<%end %\>

I’d expect to see:  
foo  
bar  
baz

My cache is up and running. What am i doing wrong?

(My environment.rb for the cache is standard:  
require ‘memcache’

memcache\_options = {  
:c\_threshold =\> 10\_000,  
:compression =\> true,  
:debug =\> false,  
:namespace =\> ‘[pazap.com](http://pazap.com)’,  
:readonly =\> false,  
:urlencode =\> false }

CACHE = MemCache.new memcache\_options  
CACHE.servers = ‘localhost:11211’)

Thanks in advance…
