开发者

Should I make a new Class in Rails for Redis?

开发者 https://www.devze.com 2023-03-31 14:51 出处:网络
I\'m starting to use Redis, and first thing my code is not too DRY, and was going to consolidate it in the application.rb and controller.Is this t开发者_StackOverflow中文版he best way to go, or should

I'm starting to use Redis, and first thing my code is not too DRY, and was going to consolidate it in the application.rb and controller. Is this t开发者_StackOverflow中文版he best way to go, or should I make a new Class called Redis, and have all the logic in there?

My models are currently Customers, Orders, Products, and I'm using a lot of counters.


You will probably need a combination of new and existing model classes.

In many cases you can just drop the model used by the view directly into the datastore, which saves repetition. However, there will always be some places where the needs of the view and the datastore are different.

For example a property that appears as a list of values in the view may need to be stored as a separate set key rather than serialized with the other properties of the model.

0

精彩评论

暂无评论...
验证码 换一张
取 消