Вопрос

If that's the case, then is it best to store stuff as JSON?

I looked in the documentation, but its not explicitly acknowledged.

Это было полезно?

Решение

Dalli uses Marshal.dump to serialize values you can store any thing that can be dumped (for example procs can't be dumped on most ruby implementations.

Personally I prefer only to store arrays, hashes, strings, numbers and combinations thereof.

Storing arbitrary objects can be inefficient (for example an activerecord object has several copies of its attributes in its instance variables).

Another potential problem is if you store an instance of a class and you later rename that class - you'll no longer be able to retrieve that value from the cache because the cached data still has the old class name in it.

Другие советы

memcache can cache everything that is serializable so even Dalli do.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top