Table of Contents
回复内容:
Home Backend Development PHP Tutorial SF的头像的存储和读取的原理是什么?

SF的头像的存储和读取的原理是什么?

Jun 06, 2016 pm 08:46 PM
php

这段时间在做个社区系统,发现用户头像是随处可见的如果通过用户ID去数据库查询,查询太频繁了,有人知道sf的头像存储和读取是怎么实现的吗?
头像地址
http://sfault-avatar.b0.upaiyun.com/377/866/3778663381-1030000000092007_huge128

http://sfault-avatar.b0.upaiyun.com/ :图片域名地址
1030000000092007 用户ID
huge128 尺寸

3778663381是什么?随机数?
377/866通过这个数生成的目录

在读取用户头像的时候是怎么读取的,通过规则来拼接地址,还是直接根据用户ID去数据库读取用户头像的地址?

回复内容:

这段时间在做个社区系统,发现用户头像是随处可见的如果通过用户ID去数据库查询,查询太频繁了,有人知道sf的头像存储和读取是怎么实现的吗?
头像地址
http://sfault-avatar.b0.upaiyun.com/377/866/3778663381-1030000000092007_huge128

http://sfault-avatar.b0.upaiyun.com/ :图片域名地址
1030000000092007 用户ID
huge128 尺寸

3778663381是什么?随机数?
377/866通过这个数生成的目录

在读取用户头像的时候是怎么读取的,通过规则来拼接地址,还是直接根据用户ID去数据库读取用户头像的地址?

去看看又拍云的文档。

用户名和id也是随处可见的,也需要频繁查询(无论存储在mysql或是别的kvdb里)。
有了用户名和id,生成一个唯一的图片名不是轻而易举。

SF的头像地址每个用户是固定的,中间的用户ID,前边的目前还不知道是什么。

不过肯定不会是是从数据库读取的,效率太低。应该是根据某种算法生成的地址,不管怎么上传头像也会是同一地址。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles