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