存储徽章标准的最佳方式? [英] Best way to store Badge criteria?

查看:127
本文介绍了存储徽章标准的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在思考如何实现徽章功能的类似SO是在一个新的网站。什么是存储标准徽章的最佳方式?

I've been thinking about how to implement the badge feature similar to SO's on a new website. What is the best way to store criteria for badges?

两个思路:


  • 所有code

  • 第二个系统 - 创建一个架构元用于定义徽章和他们的标准。存储在数据库中的一些信息,并有code查询它来计算出徽章和他们的标准。

有没有更好的办法呢?

推荐答案

规则。

您创建一个事件流处理器内的系统事件和使​​用规则。

You create events in the system, and use rules within an event stream processor.

具体来说,说你有一个徽章造10个职位。你不要跑,从帖子SELECT COUNT(*),其中用户=:用户为每一个岗位。相反,你有一个简单的规则,手表各岗位得的,和算他们,存储在用户配置文件中的规则状态。

Specifically, say you have a badge "made 10 posts". You don't run "select count(*) from posts where user = :user" for every post. Rather, you have a simple rule that watches each post come by, and "count them", storing the rules state in the user profile.

这条道路提出10个职位是了1百万的帖子一样便宜。

That way "made 10 posts" is as cheap as "made 1,000,000" posts.

这也使得系统更可扩展性。

This also makes the system much more extensible.

这篇关于存储徽章标准的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆