# Memcached vs. activerecord

**URL:** <https://www.ruby-forum.com/t/memcached-vs-activerecord/132620>\
**Category:** Rails\
**Created:** [March 21, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/memcached-vs-activerecord/132620 "2008-03-21T23:45:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [March 21, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/memcached-vs-activerecord/132620/1 "2008-03-21T23:45:22Z")

</div>

I know I’m inviting the full wrath of a lot of purists but I thought I’d  
ask anyway. Is there a way to store a model (activerecord based one)  
straight into memcached and skip the database all together?

Basically I’d like to make a bunch of web service calls, instantiate  
some objects from the results (like :user, :user\_interests,  
:user\_friends, etc based on the normal Rails associations) write it to  
memcache and read it back

Let the thrashing begin …

GP

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [March 21, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/memcached-vs-activerecord/132620/2 "2008-03-21T23:52:13Z")

</div>

It’s not a guaranteed storage area. If that’s fine, then I see no  
problem with it.

Jason

On Fri, Mar 21, 2008 at 6:45 PM, Grayson P.

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [March 22, 2008, 12:17am UTC](https://www.ruby-forum.com/t/memcached-vs-activerecord/132620/3 "2008-03-22T00:17:57Z")

</div>

Grayson P. wrote:

> I know I’m inviting the full wrath of a lot of purists but I thought I’d  
> ask anyway. Is there a way to store a model (activerecord based one)  
> straight into memcached and skip the database all together?
> 
> Basically I’d like to make a bunch of web service calls, instantiate  
> some objects from the results (like :user, :user\_interests,  
> :user\_friends, etc based on the normal Rails associations) write it to  
> memcache and read it back

So where do you get the data from? How do the models know what  
attributes they have? How long does this data need to persist?

=matthew

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [March 22, 2008, 4:01pm UTC](https://www.ruby-forum.com/t/memcached-vs-activerecord/132620/4 "2008-03-22T16:01:41Z")

</div>

Cool, not the question is how? Do I create some non-ActiveRecord  
classes, load the web service results into those, put them into an array  
and give it to memcached?

Thanks,

GP  
Jason R. wrote:

> It’s not a guaranteed storage area. If that’s fine, then I see no  
> problem with it.
> 
> Jason
> 
> On Fri, Mar 21, 2008 at 6:45 PM, Grayson P.
