Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antirez/retwis
A Twitter-toy clone written in PHP and Redis, used in the early days to introduce Redis data types.
https://github.com/antirez/retwis
Last synced: 10 days ago
JSON representation
A Twitter-toy clone written in PHP and Redis, used in the early days to introduce Redis data types.
- Host: GitHub
- URL: https://github.com/antirez/retwis
- Owner: antirez
- License: bsd-3-clause
- Created: 2014-05-28T09:09:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T06:02:27.000Z (over 6 years ago)
- Last Synced: 2024-07-31T12:07:28.666Z (3 months ago)
- Language: PHP
- Size: 277 KB
- Stars: 366
- Watchers: 26
- Forks: 140
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
- favorite-link - 一个用 PHP 和 Redis 编写的 Twitter 玩具克隆,在早期用于介绍 Redis 数据类型。
README
Retwis is the Redis Hello World. A minimal Twitter-style social network clone
written using Redis and PHP. The source code is designed to be very simple and
at the same time to show different Redis data structures.You can find a tutorial explaining step by step how the example was created
in the [Twitter clone tutorial of the Redis documentation](http://redis.io/topics/twitter-clone).This code was written back in 2009 when Redis was initially published, in order
to expose interested developers to the Redis concepts and data types.
Later, in May 2014, it was reworked in order to update it to *modern Redis*,
since when the example was introduced Redis lacked sorted sets, hashes,
and many other features.The following is a description of the data layout.
Users
---User IDs are generated sequencially via increments:
INCR next_user_id => 1000
(We'll use the example user ID 1000 in the next examples)
Users are stored into Redis hashes, the key name of the hash representing a
given user is `user:1000`. Every hash has the following fields:username (the username of the user)
password (password of course)
auth 9458sd893448dfdThere are additional keys for following, followers, and posts:
following:1000 (sorted set of user ids)
followers:1000 (sorted set of user ids)
posts:1000 (list of posts ids)In order to reverse lookup the user ID from the authentication toke or
username we have the following two additional keys:The key `auths` is an hash mapping auth tokens to user IDs.
Example of field and value: 9458sd893448dfd => 1000The key `users` is an hash mapping usernames to user IDs.
Example of field and value: antirez => 1000Additionally we take a sorted set with usernames indexed by registration
time (the score is the unix time the user joined), so that we can populate
our "latest users" view. The key is called `users_by_time`.Posts
---Posts also have sequencial IDs, generated by incrementing the following key:
INCR next_post_id => 134
Every post is stored into an hash named `post:134` with the following
fields:user_id
time
bodyTimeline
---Just a list of post IDs in the `timeline` key.