Frage

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

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

War es hilfreich?

Lösung

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.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top