如何构建Google数据存储(App Engine)Web流量模型? [英] How to structure Google Datastore (App Engine) web traffic model?

查看:121
本文介绍了如何构建Google数据存储(App Engine)Web流量模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单任务:跟踪网络流量(点击量),以便我可以绘制过去30天内每天的点击次数。

当前数据存储模型(2个字段):1)网站ID 2)点击时间戳

问题:我正在使用Google App Engine的数据存储,但无法进行分组或计数。

任何人都可以提供一种简单的方法来构建我的Google Datastore数据库以实现此任务吗?通过返回所有匹配,然后将它们分组在我的代码中看起来像一个表演猪。有任何想法吗?

解决方案

我会为这个特定的任务使用分片计数器;请参阅文档的最后一个示例。


Simple Task: keep track of web traffic (hits) so that I can graph the number of hits per day for the last 30 days.

Current Datastore Model (2 fields): 1) Website ID 2) Timestamp of Hit

Problem: I'm using Google App Engine's datastore and don't have the ability to do a group-by or count.

Can anyone offer a simple way to structure my Google Datastore database to achieve this task? By returning all of the hits and then grouping them in my code seems like a performance hog. Any ideas?

解决方案

I would use sharding counters for this specific task; have a look to the last example of this documentation.

这篇关于如何构建Google数据存储(App Engine)Web流量模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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