Home Database Mysql Tutorial 如何将Sphinx配置成缓存服务器

如何将Sphinx配置成缓存服务器

Jun 07, 2016 pm 04:28 PM
sphinx how server Know cache Configuration

大家都知道Sphinx是一个全文索引程序,它的高速查询能力也是有目共睹的。除了这些,我们是否还能挖掘点别的功能出来呢?不如作为一个简单的缓存服务器。 先来了解下Sphinx的使用的文件,Sphinx使用的文件包括 .sph, .spa, .spi, .spd, .spp, .spm ,.spl

大家都知道Sphinx是一个全文索引程序,它的高速查询能力也是有目共睹的。除了这些,我们是否还能挖掘点别的功能出来呢?不如作为一个简单的缓存服务器。

Sphinx

先来了解下Sphinx的使用的文件,Sphinx使用的文件包括 .sph, .spa, .spi, .spd, .spp, .spm ,.spl。

  • sph:头文件,保存的是系统的配置文件。
  • spi:保存WordId及指向此WordId对应的文档信息在spd文件的指针, spi文件在检索程序启动时完全加载入内存。 spi文件是分块的,块内排序,块之间也排序。分块的目的应该是为了快速检索到WordId, 因为spi中的WordId是变长压缩的,索引需要先在块级别做二分定位,再在快内解压缩查找。
  • spa:存储DocInfo的文件,检索程序启动时会把此文件加载如内存,sphinx可以指定DocInfo的存储方式:
    • inline:存储到spd文件中。
    • extern:单独存储,就会生成spa文件。
  • spd:文档列表。
  • spp:关键字所在位置列表。
  • spm:在DocInfo中,有一种特殊的属性,叫MVA,多值属性。 Sphinx对此属性特殊处理,需要存储在spm文件中。 检索程序启动时会把此文件加载如内存。 此属性在DocInfo对应位置存储其在此文件中的字节偏移量。
  • spk:killlist
  • spl:索引锁

通过介绍可以得知Sphinx存储的文档的属性,在0.98之前的版本是不存储的,我们是不是可以利用这些数据作为缓存使用呢,根据DocID获取文档的信息。

通过hack搜索服务添加SEARCHD_COMMAND_DOCINFO指令,客户端API添加GetDocinfo函数可以达到预期的效果。

php示例代码:

require 'sphinxapi.php';
$cl = new SphinxClient ();
$cl->SetServer();
$res = $cl->GetDocinfo(1, 'singer');
print_r($res);
Copy after login

结果如下:

Array
(
    [singer_id] => 1
    [singer_name] => 阿牛
    [cate_id] => 1
    [tag_ids] => Array
        (
            [0] => 110
            [1] => 114
            [2] => 127
        )
    [song_number] => 137
    [album_number] => 14
)
Copy after login

Patch文件 : https://gist.github.com/2251422

参考文章

  • sphinx简析
  • sphinx的spx文件格式
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)

Hot Topics

Java Tutorial
1673
14
PHP Tutorial
1278
29
C# Tutorial
1257
24
How to configure Dnsmasq as a DHCP relay server How to configure Dnsmasq as a DHCP relay server Mar 21, 2024 am 08:50 AM

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

Best Practice Guide for Building IP Proxy Servers with PHP Best Practice Guide for Building IP Proxy Servers with PHP Mar 11, 2024 am 08:36 AM

In network data transmission, IP proxy servers play an important role, helping users hide their real IP addresses, protect privacy, and improve access speeds. In this article, we will introduce the best practice guide on how to build an IP proxy server with PHP and provide specific code examples. What is an IP proxy server? An IP proxy server is an intermediate server located between the user and the target server. It acts as a transfer station between the user and the target server, forwarding the user's requests and responses. By using an IP proxy server

How to configure and install FTPS in Linux system How to configure and install FTPS in Linux system Mar 20, 2024 pm 02:03 PM

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline Mar 13, 2024 pm 04:40 PM

What should I do if I can’t enter the game when the epic server is offline? This problem must have been encountered by many friends. When this prompt appears, the genuine game cannot be started. This problem is usually caused by interference from the network and security software. So how should it be solved? The editor of this issue will explain I would like to share the solution with you, I hope today’s software tutorial can help you solve the problem. What to do if the epic server cannot enter the game when it is offline: 1. It may be interfered by security software. Close the game platform and security software and then restart. 2. The second is that the network fluctuates too much. Try restarting the router to see if it works. If the conditions are OK, you can try to use the 5g mobile network to operate. 3. Then there may be more

Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Equipped with AMD EPYC 4004 series processors, ASUS launches a variety of server and workstation products Jul 23, 2024 pm 09:34 PM

According to news from this website on July 23, ASUS has launched a variety of server and workstation-level products powered by AMD EPYC 4004 series processors. Note from this site: AMD launched the AM5 platform and Zen4 architecture EPYC 4004 series processors in May, offering up to 16-core 3DV-Cache specifications. ASUSProER100AB6 server ASUSProER100AB6 is a 1U rack server product equipped with EPYC Xiaolong 4004 series processor, suitable for the needs of IDC and small and medium-sized enterprises. ASUSExpertCenterProET500AB6 workstation ASUSExpertCenterProET500AB6 is a

How to install PHP FFmpeg extension on server? How to install PHP FFmpeg extension on server? Mar 28, 2024 pm 02:39 PM

How to install PHPFFmpeg extension on server? Installing the PHPFFmpeg extension on the server can help us process audio and video files in PHP projects and implement functions such as encoding, decoding, editing, and processing of audio and video files. This article will introduce how to install the PHPFFmpeg extension on the server, as well as specific code examples. First, we need to ensure that PHP and FFmpeg are installed on the server. If FFmpeg is not installed, you can follow the steps below to install FFmpe

How to use caching in Golang distributed system? How to use caching in Golang distributed system? Jun 01, 2024 pm 09:27 PM

In the Go distributed system, caching can be implemented using the groupcache package. This package provides a general caching interface and supports multiple caching strategies, such as LRU, LFU, ARC and FIFO. Leveraging groupcache can significantly improve application performance, reduce backend load, and enhance system reliability. The specific implementation method is as follows: Import the necessary packages, set the cache pool size, define the cache pool, set the cache expiration time, set the number of concurrent value requests, and process the value request results.

See all articles