ITeye博客

Ruby面试系列四,新鲜刚出炉的面试题

夜鸣猪 · 2011-10-13 04:47 · RubyOnRails · 编程语言 · Markdown

这次是留的家庭作业

Write a model (ActiveRecord-based, or similar pattern) for storing configuration settings.

Each setting should have a unique identifier such as a name, and should hold a single value. For example: an email address used to send error emails, or a boolean flag to enable/disable a particular feature. It must be possible to store values of at least these 4 types: string, integer, float and boolean.

The purpose of this exercise is to show your code design skills. Therefore, the model's interface for reading and writing configuration values must be simple and convenient. It should be possible to read and write specific values, versus reading and writing all the configuration settings all at once. The model should come with unit tests and database migrations, or whatever is required given your persistent storage setup.

Bonus: add caching so that values don't need to be read from the database every time they are accessed. If using Ruby on Rails, consider using standard Rails caching techniques for this. HTML caching should not be required.

这个个加分的缓存是说啥呢

评论(2)

  1. #2 楼 · 夜鸣猪 · 2011-10-13 20:38

    Rails.cache ?

  2. #1 楼 · orcl_zhang · 2011-10-13 10:41

    把configuration model缓存起来,model的缓存。

评论功能维护中,当前仅展示历史评论。