WO2017008659A1 - 一种获取域名后缀的方法及装置 - Google Patents
一种获取域名后缀的方法及装置 Download PDFInfo
- Publication number
- WO2017008659A1 WO2017008659A1 PCT/CN2016/088520 CN2016088520W WO2017008659A1 WO 2017008659 A1 WO2017008659 A1 WO 2017008659A1 CN 2016088520 W CN2016088520 W CN 2016088520W WO 2017008659 A1 WO2017008659 A1 WO 2017008659A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- cache
- domain name
- configuration data
- name suffix
- suffix
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/45—Network directories; Name-to-address mapping
- H04L61/4505—Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
- H04L61/4511—Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9014—Indexing; Data structures therefor; Storage structures hash tables
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
Definitions
- the invention belongs to the technical field of computers, and in particular relates to a method and a device for acquiring a domain name suffix.
- domain name suffixes are often required.
- domain name suffix for example: "alibaba-inc.com”
- the suffix is ".com”.
- domain name suffixes are increasing.
- the domain name suffixes that need to be maintained in an application are also frequently changed. It is difficult to obtain and maintain domain name suffixes.
- the current domain name suffix data exists in the configuration item of the application system database. After each configuration item is modified, the application system needs to be restarted, that is, each maintenance needs to be re-released. At the same time, the existing domain name suffix acquisition mode needs to traverse the configuration item. From the highest suffix domain name, the second-level domain name suffix and the top-level domain name suffix are always inefficient.
- the object of the present invention is to provide a method and a device for obtaining a domain name suffix, and provide an independent domain name suffix service for the application system, thereby improving the efficiency of the application obtaining the domain name suffix and facilitating maintenance.
- a method for obtaining a domain name suffix including:
- the corresponding domain name suffix is obtained by querying in the cache.
- the step of clearing the cache is further included.
- the step of enabling the cache write lock is further included;
- the method further includes closing the cache write lock. step.
- the cache By turning on the write lock before updating the cache and closing the write lock after the update, the cache can be effectively protected from concurrent operations without confusion and the update process is accurate.
- the configuration data includes a domain name suffix and a domain name suffix level.
- the updating the cache with the obtained configuration data includes:
- the hash value is matched with the length of the hash table array to obtain the corresponding hash table array position;
- the domain name suffix is placed in the hash table
- the maximum domain name suffix level of all domain name suffixes in the configuration data is stored in the cache.
- the invention uses a hash table to store the domain name suffix, which is convenient for searching. When searching, it only needs to compare the domain name suffix with the length of the hash table array, and find the domain name suffix of the corresponding location for comparison.
- the configuration data is read by the present invention, and the cache is updated into an independent thread by using the obtained configuration data, and the independent thread is repeatedly executed periodically.
- the method of the present invention includes the step of enabling the cache read lock before querying the corresponding domain name suffix in the cache;
- the operations of unlocking and blocking are also performed, which is advantageous for preventing concurrent operations and ensuring that the cache is not erroneously rewritten.
- the querying the corresponding domain name suffix in the cache according to the input query parameter and the domain name suffix level in the cache further includes: matching, by using a regular expression, the domain name that needs to be queried from the query parameter.
- the query obtains the corresponding domain name suffix in the cache, including:
- a regular expression is generated according to the obtained domain name suffix level, and is matched with the domain name that needs to be queried. After the matching, the judgment is performed to determine whether the matched result is in the cache. If the cache hits, the matching result is returned. In the cache, the domain suffix level is decremented by one, the regular expression is regenerated, and the matching continues until the matching result is returned or null.
- the invention also provides an apparatus for obtaining a domain name suffix, comprising:
- a cache update module configured to read configuration data, and update the cache with the obtained configuration data
- the suffix query module is configured to query the cache to obtain the corresponding domain name suffix according to the input query parameter and the domain name suffix level in the cache.
- the cache update module is further configured to clear the cache before updating the cache with the acquired configuration data after reading the configuration data.
- the cache update module is further configured to:
- the configuration data of the present invention includes a domain name suffix and a domain name suffix level.
- the hash value is matched with the length of the hash table array to obtain the corresponding hash table array position;
- the domain name suffix is placed in the hash table
- the maximum domain name suffix level of all domain name suffixes in the configuration data is stored in the cache.
- the cache update module periodically reads the configuration data repeatedly, and updates the cache with the obtained configuration data.
- suffix query module is further configured to:
- the cache read lock is enabled
- the cache read lock is closed.
- the suffix query module is further configured to match, by using a regular expression, the domain name that needs to be queried from the query parameters.
- the suffix query module performs the following operations when querying the corresponding domain name suffix in the cache according to the input query parameter and the domain name suffix level in the cache:
- a regular expression is generated according to the obtained domain name suffix level, and is matched with the domain name that needs to be queried. After the matching, the judgment is performed to determine whether the matched result is in the cache. If the cache hits, the matching result is returned. In the cache, the domain suffix level is decremented by one, the regular expression is regenerated, and the matching continues until the matching result is returned or null.
- the method and device for obtaining a domain name suffix are provided by locating a domain name suffix in a system database configuration item in a memory hash table, and obtaining a domain name suffix corresponding to the query parameter by using a regular expression, thereby improving the overall acquisition.
- the speed of the domain name suffix is provided by periodically updating the cache, there is no need to re-release the entire application system, and the maintainability is high.
- FIG. 1 is a flowchart of a method for obtaining a domain name suffix according to the present invention
- FIG. 2 is a schematic structural diagram of a hash table in a cache according to the present invention.
- FIG. 3 is a schematic structural diagram of an apparatus for acquiring a domain name suffix according to the present invention.
- the general idea of the present invention is that in the Internet application system, the domain name suffix in the database configuration item is cached in the memory, so that the application system obtains the domain name suffix through the regular expression.
- a method for obtaining a domain name suffix in the embodiment includes the following steps:
- This embodiment takes the Java language as an example.
- the InitializingBean interface is implemented by a defined Java class.
- the afterPropertiest method is called to create and start a single update cache thread, and initialize the cache data. Perform the steps to write configuration data to the cache.
- the configuration data is read, and the cache is updated by using the obtained configuration data, including the following steps:
- the configuration data in this embodiment includes a domain name suffix and a corresponding domain name suffix level.
- the configuration data in an application system configuration item is as follows:
- the acquired configuration data is used to update the cache.
- the specific form of the cache in this embodiment is a hash table, and the hash table can improve the query speed.
- the cache is updated by using the obtained configuration data, and the specific method is as follows:
- Each domain name suffix is hashed to obtain a corresponding hash value
- the hash value is matched with the length of the hash table array to obtain the corresponding hash table array position;
- the domain name suffix is placed in the hash table according to the hash table array location.
- the maximum domain name suffix level in the above domain name suffix is separately stored in the cache.
- the default domain name suffix level is 2.
- the default domain name suffix level is 2. If the domain name suffix level of the configuration data in the database is greater than 2 in the future, it will be updated at the same time when the cache is updated. The maximum domain name suffix level in the cache.
- the write lock is turned on before the cache is updated, and then the write lock is closed, which can effectively avoid the concurrency problem, that is, no conflict occurs in concurrent operations.
- the process of updating the cache in this embodiment is a separate thread, and the process may be repeatedly performed periodically to update the cached configuration data, and the repetition period may be determined according to requirements.
- the timer task thread is maintained by Executors.newSingleThreadScheduledExecutor() to avoid the update thread from stopping due to an unexpected interruption of the thread.
- S2 Query the cached domain name suffix according to the input query parameter and the domain name suffix level in the cache.
- the domain name suffix can be queried for the defined Java object, including the following steps:
- the query parameter input in this embodiment may be a domain name that needs to be queried, or may be a string including a domain name, such as a URL.
- a domain name suffix level When querying the domain name suffix, create a regular expression according to the domain name suffix level, and search for the part of the input domain name that matches the regular expression by recursively, and determine whether it exists in the cache. If it does not exist, the domain name suffix level is decremented again. Until the domain name suffix or the current suffix level is equal to 0.
- the input query parameter is not a domain name, but a URL, for example: http://www.alibaba-inc.com; then need to pass the regular expression "(http://
- the URL entered is: http://www.alibaba-inc.com; then it matches: www.alibaba-inc.com.
- the domain name suffix level is obtained from the cache.
- the domain name suffix level is the domain name suffix level read from the cache, that is, the maximum level of the current domain name suffix, and the domain name suffix level in the cache is 2.
- the spliced regular expression is: ( ⁇ . ⁇ 1 ⁇ [ ⁇ .]+ ⁇ . ⁇ 1 ⁇ [ ⁇ .]+)$;
- the apparatus for obtaining a domain name suffix based on the foregoing method according to the foregoing method includes:
- a cache update module configured to read configuration data, and update the cache with the obtained configuration data
- the suffix query module is configured to query the cache to obtain the corresponding domain name suffix according to the input query parameter and the domain name suffix level in the cache.
- the cache update module is further configured to clear the cache before updating the cache with the obtained configuration data after reading the configuration data. And, the cache update module is further configured to:
- the configuration data of the embodiment includes a domain name suffix and a domain name suffix level
- the cache update module performs the following operations when updating the cache with the obtained configuration data:
- the hash value is matched with the length of the hash table array to obtain the corresponding hash table array position;
- the domain name suffix is placed in the hash table
- the maximum domain name suffix level of all domain name suffixes in the configuration data is stored in the cache.
- the cache update module periodically reads the configuration data and updates the cache with the obtained configuration data.
- the suffix query module is further used to:
- the cache read lock is enabled
- the cache read lock is closed.
- the suffix query module of this embodiment is further configured to match, by using a regular expression, the domain name that needs to be queried from the query parameters.
- suffix query module is in the cache according to the input query parameter and the domain name suffix level in the cache.
- the query gets the corresponding domain name suffix, perform the following operations:
- a regular expression is generated according to the obtained domain name suffix level, and is matched with the domain name that needs to be queried. After the matching, the judgment is performed to determine whether the matched result is in the cache. If the cache hits, the matching result is returned. In the cache, the domain suffix level is decremented by one, the regular expression is regenerated, and the matching continues until the matching result is returned or null.
- the configuration items in the database can be configured without re-publishing the application system, and then the cache is re-updated, thereby improving the speed of obtaining the domain name suffix as a whole, and the maintainability is high.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种获取域名后缀的方法及装置,所述方法包括:读取配置数据,用获取到的配置数据更新缓存;根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。本发明的装置包括缓存更新模块和后缀查询模块。本发明的方法及装置,通过将配置项中的域名后缀缓存在内存哈希表中,同时通过正则表达式获取查询参数对应的域名后缀,整体上提高了获取域名后缀的速度,并且通过周期性更新缓存,不需要重新发布整个应用系统,可维护性高。
Description
本申请要求2015年07月14日递交的申请号为201510411936.8、发明名称为“一种获取域名后缀的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本发明属于计算机技术领域,尤其涉及一种获取域名后缀的方法及装置。
在计算机应用程序的开发中,特别是互联网应用系统,经常需要用到域名后缀。如域名解析系统,在添加域名的时候需要判断系统是否支持该类域名,就需要去获取本系统所配置了的域名后缀。所谓域名后缀,例如:“alibaba-inc.com”,获取的后缀为“.com”。目前域名后缀越来越多,在一个应用程序中需要维护的域名后缀也经常变化,对于域名后缀的获取和维护都比较困难。
现在的域名后缀数据都存在于应用系统数据库的配置项中,在每次修改配置项后都需要重启应用系统,即每次维护都需要重新发布。同时现有域名后缀获取方式需要遍历配置项,从最高位后缀域名,一直比对到二级域名后缀、顶级域名后缀,效率不高。
发明内容
本发明的目的是提供一种获取域名后缀的方法及装置,为应用系统提供独立域名后缀服务,从而提高应用程序获取域名后缀的效率,同时便于维护。
为了实现上述目的,本发明技术方案如下:
一种获取域名后缀的方法,包括:
读取配置数据,用获取到的配置数据更新缓存;
根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
进一步地,在所述读取配置数据之后,用获取到的配置数据更新缓存之前,还包括清除缓存的步骤。
在所述读取配置数据,用获取到的配置数据更新缓存之前,还包括开启缓存写锁的步骤;
在所述读取配置数据,用获取到的配置数据更新缓存之后,还包括关闭缓存写锁的
步骤。
通过在更新缓存前开启写锁,并在更新后关闭写锁,可以有效保护缓存在并发操作时,不会发生混乱,保证更新过程的准确。
本发明中,所述配置数据包括域名后缀及域名后缀级别。所述用获取到的配置数据更新缓存,包括:
对配置数据中的每个域名后缀,经过哈希计算得到对应的哈希值;
将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;
根据该哈希表数组位置,将该域名后缀放入哈希表中;
取配置数据中所有域名后缀的最大域名后缀级别存储在缓存中。
本发明采用哈希表存储域名后缀,方便查找,在查找时只需根据域名后缀与哈希表数组长度相与,找到对应位置的域名后缀进行比较即可。
进一步地,本发明所述读取配置数据,用获取到的配置数据更新缓存为一个独立线程,所述独立线程定期重复执行。
进一步地,本发明所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之前,还包括开启缓存读锁的步骤;
所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之后,还包括关闭缓存读锁的步骤。
同样在对缓存进行操作时,还执行开锁和闭锁的操作,有利与防止并发操作,并保证缓存不被错误地重写。
进一步地,所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀,还包括:通过正则表达式从所述查询参数中匹配出需要进行查询的域名。
进一步地,所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀,包括:
获取缓存中的域名后缀级别;
根据获取的域名后缀级别,生成正则表达式,与所述需要进行查询的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果,如果不在缓存中,则令域名后缀级别减一,重新生成正则表达式,继续进行匹配,直到返回匹配结果或返回空。
本发明还提出了一种获取域名后缀的装置,包括:
缓存更新模块,用于读取配置数据,用获取到的配置数据更新缓存;
后缀查询模块,用于根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
进一步地,所述缓存更新模块还用于在读取配置数据之后,用获取到的配置数据更新缓存之前,清除缓存。
所述缓存更新模块还用于:
在读取配置数据,用获取到的配置数据更新缓存之前,开启缓存写锁;
在读取配置数据,用获取到的配置数据更新缓存之后,关闭缓存写锁。
本发明所述配置数据包括域名后缀及域名后缀级别,所述缓存更新模块在用获取到的配置数据更新缓存时,执行如下操作:
对配置数据中的每个域名后缀,经过哈希计算得到对应的哈希值;
将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;
根据该哈希表数组位置,将该域名后缀放入哈希表中;
取配置数据中所有域名后缀的最大域名后缀级别存储在缓存中。
进一步地,所述缓存更新模块定期重复读取配置数据,用获取到的配置数据更新缓存。
进一步地,所述后缀查询模块还用于:
在根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之前,开启缓存读锁;
根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之后,关闭缓存读锁。
进一步地,所述后缀查询模块还用于通过正则表达式从所述查询参数中匹配出需要进行查询的域名。
其中,所述后缀查询模块在根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀时,执行如下操作:
获取缓存中的域名后缀级别;
根据获取的域名后缀级别,生成正则表达式,与所述需要进行查询的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果,如果不在缓存中,则令域名后缀级别减一,重新生成正则表达式,继续进行匹配,直到返回匹配结果或返回空。
本发明提供的一种获取域名后缀的方法及装置,通过将系统数据库配置项中的域名后缀缓存在内存哈希表中,同时通过正则表达式获取查询参数对应的域名后缀,整体上提高了获取域名后缀的速度。并且通过周期性更新缓存,不需要重新发布整个应用系统,可维护性高。
图1为本发明获取域名后缀的方法流程图;
图2为本发明缓存中哈希表的结构示意图;
图3为本发明获取域名后缀的装置结构示意图。
下面结合附图和实施例对本发明技术方案做进一步详细说明,以下实施例不构成对本发明的限定。
本发明的总体思路是在互联网应用系统中,通过将存在数据库配置项中的域名后缀缓存在内存中,便于应用系统通过正则表达式获取域名后缀。
如图1所示,本实施例一种获取域名后缀的方法,包括如下步骤:
S1、读取配置数据,用获取到的配置数据更新缓存;
本实施例以Java语言为例来进行说明,具体地,通过定义的Java类,实现InitializingBean接口,在Java对象初始化完成后,调用afterPropertiest方法,创建并启动单个更新缓存的线程,初始化缓存数据,来执行将配置数据写入缓存的步骤。
本实施例读取配置数据,用获取到的配置数据更新缓存,包括如下步骤:
开启写锁;
读取数据库中的配置数据;
清除缓存;
遍历配置数据,用获取到的配置数据更新缓存;
关闭写锁。
本实施例中的配置数据包含域名后缀和对应的域名后缀级别,例如一个应用系统配置项中的配置数据如下表:
表1应用系统配置项中的配置数据表
统一标识符 | 创建时间 | 域名后缀 | 域名后缀级别 |
1 | 2015-01-21 17:31:00 | .ac.cn | 2 |
10 | 2015-01-21 17:31:00 | .jl.cn | 2 |
100 | 2015-02-03 10:09:00 | .solar | 1 |
1000 | 2015-02-03 10:09:00 | .forex | 1 |
1001 | 2015-02-03 10:09:00 | .bmw | 1 |
1002 | 2015-02-03 10:09:00 | .day | 1 |
1003 | 2015-02-03 10:09:00 | .lds | 1 |
1004 | 2015-02-03 10:09:00 | .fast | 1 |
1005 | 2015-02-03 10:09:00 | .bms | 1 |
1006 | 2015-02-03 10:09:00 | .insurance | 1 |
1007 | 2015-02-03 10:09:00 | .spreadbetting | 1 |
1008 | 2015-02-03 10:09:00 | .edu.cn | 2 |
1009 | 2015-02-03 10:09:00 | .farm | 1 |
101 | 2015-02-03 10:09:00 | .购物 | 1 |
1010 | 2015-02-03 10:09:00 | .weatherchannel | 1 |
1011 | 2015-02-03 10:09:00 | .author | 1 |
在获取到应用系统配置项的配置数据之后,使用获取的配置数据来更新缓存。本实施例中缓存的具体形式是哈希表,使用哈希表能够提高查询速度。本实施例用获取到的配置数据更新缓存,具体方法如下:
对每个域名后缀经过哈希计算得到对应的哈希值;
将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;
根据该哈希表数组位置,将该域名后缀放入哈希表中。
需要说明的是,如果哈希值相同,域名后缀内容不相同,则以链表的形式顺序排列。将所有域名后缀都添加完成后,得到如图2所示的数据结构示意图,其中.ac.cn与.jl.cn以链表的形式顺序排列,.farm与.name、.pay以链表的形式顺序排列。
同时,对于表1中的域名后缀级别,取上述域名后缀中的最大域名后缀级别单独存储在缓存中。因为目前常用域名后缀最多2级,因此本实施例中规定默认域名后缀级别为2。如果将来数据库中的配置数据的域名后缀级别大于2,则在更新缓存时,同时更新
缓存中该最大域名后缀级别。
本实施例中在更新缓存之前先开启写锁,之后关闭写锁,能够有效避免并发问题,即在并发操作时不会造成冲突。
需要说明的是,本实施例更新缓存的过程是一个独立线程,可以定期重复执行这个过程,更新缓存的配置数据,重复周期可根据需求而定。例如:通过Executors.newSingleThreadScheduledExecutor()维护定时任务线程,从而避免因为线程的意外中断导致更新线程停止。
S2、根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
在用获取的配置数据更新缓存后,则可以针对定义的Java对象来进行域名后缀的查询,具体包括如下步骤:
开启读锁;
获取域名后缀;
关闭读锁。
同样地,在获取域名后缀之前要开启缓存的读锁,并且在之后关闭,这样能够有效防止并发问题,整体上提高了获取域名的速度。
本实施例输入的查询参数可以是需要查询的域名,也可以是包括域名的字符串,例如URL。在查询域名后缀时,根据域名后缀级别,创建正则表达式,通过递归的方法查找输入的域名中与正则表达式匹配的部分,在缓存中判断是否存在,不存在则域名后缀级别递减再次获取,直到得到域名后缀或当前后缀级别等于0。
举例如下:
在查询时,如果输入的查询参数不是域名,而是URL,例如:http://www.alibaba-inc.com;则需要根据通过正则表达式"(http://|https://)?([^:/]+)(/|:)*?"进行初步过滤,匹配出需要进行查询的域名部分。
例如输入的URL为:http://www.alibaba-inc.com;则匹配出:www.alibaba-inc.com。
如输入查询参数直接是域名,例如:www.alibaba-inc.com,则直接用其作为需要查询的域名。接着从缓存中获取域名后缀级别,该域名后缀级别是从缓存中读取的域名后缀级别,即目前域名后缀的最大级别,而缓存中的域名后缀级别为2。
然后根据从缓存中获取的域名后缀级别(假设值为N),拼接N次正则表达式,形如(\\.{1}[^.]+")$,小括号内部部分重复N次,采用递归的方法进行查询。即根据N,拼
接正则表达式,然后与输入的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果;如果不在缓存中,则令N=N-1,重新生成正则表达式,再次执行上述查询步骤,直到有返回值,或者N等于0,返回null。
例如当N=2时,拼接的正则表达式为:(\\.{1}[^.]+\\.{1}[^.]+)$;
匹配出:.alibaba-inc.com,显然该结果不在缓存中;
则令N=2-1=1,拼接的正则表达式为:(\\.{1}[^.]+)$
进行再次匹配,获取得到域名后缀:.com,缓存命中,返回最后的结果:.com。
如图3所示,本实施例基于上述方法的一种获取域名后缀的装置,包括:
缓存更新模块,用于读取配置数据,用获取到的配置数据更新缓存;
后缀查询模块,用于根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
与方法对应地,缓存更新模块还用于在读取配置数据之后,用获取到的配置数据更新缓存之前,清除缓存。并且,所述缓存更新模块还用于:
在读取配置数据,用获取到的配置数据更新缓存之前,开启缓存写锁;
在读取配置数据,用获取到的配置数据更新缓存之后,关闭缓存写锁。
与本发明方法对应地,本实施例配置数据包括域名后缀及域名后缀级别,则缓存更新模块在用获取到的配置数据更新缓存时,执行如下操作:
对配置数据中的每个域名后缀,经过哈希计算得到对应的哈希值;
将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;
根据该哈希表数组位置,将该域名后缀放入哈希表中;
取配置数据中所有域名后缀的最大域名后缀级别存储在缓存中。
并且,缓存更新模块定期重复读取配置数据,用获取到的配置数据更新缓存。
与本发明方法对应地,后缀查询模块还用于:
在根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之前,开启缓存读锁;
根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之后,关闭缓存读锁。
与本发明方法对应地,本实施例后缀查询模块还用于通过正则表达式从所述查询参数中匹配出需要进行查询的域名。
进一步地,后缀查询模块在根据输入的查询参数及缓存中的域名后缀级别,在缓存
中查询得到对应的域名后缀时,执行如下操作:
获取缓存中的域名后缀级别;
根据获取的域名后缀级别,生成正则表达式,与所述需要进行查询的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果,如果不在缓存中,则令域名后缀级别减一,重新生成正则表达式,继续进行匹配,直到返回匹配结果或返回空。
通过上述方法及装置,能够在不重新发布应用系统的情况下,对数据库中的配置项进行配置,并随后重新更新缓存,整体上提高了获取域名后缀的速度,且可维护性高。
以上实施例仅用以说明本发明的技术方案而非对其进行限制,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员当可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。
Claims (18)
- 一种获取域名后缀的方法,其特征在于,包括:读取配置数据,用获取到的配置数据更新缓存;根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
- 根据权利要求1所述的方法,其特征在于,在所述读取配置数据之后,用获取到的配置数据更新缓存之前,还包括清除缓存的步骤。
- 根据权利要求2所述的方法,其特征在于:在所述读取配置数据,用获取到的配置数据更新缓存之前,还包括开启缓存写锁的步骤;在所述读取配置数据,用获取到的配置数据更新缓存之后,还包括关闭缓存写锁的步骤。
- 根据权利要求1所述的方法,其特征在于,所述配置数据包括域名后缀及域名后缀级别。
- 根据权利要求4所述的方法,其特征在于,所述用获取到的配置数据更新缓存,包括:对配置数据中的每个域名后缀,经过哈希计算得到对应的哈希值;将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;根据该哈希表数组位置,将该域名后缀放入哈希表中;取配置数据中所有域名后缀的最大域名后缀级别存储在缓存中。
- 根据权利要求1所述的方法,其特征在于,所述读取配置数据,用获取到的配置数据更新缓存为一个独立线程,所述独立线程定期重复执行。
- 根据权利要求1所述的方法,其特征在于:所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之前,还包括开启缓存读锁的步骤;所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之后,还包括关闭缓存读锁的步骤。
- 根据权利要求1所述的方法,其特征在于,所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀,还包括:通过正则表达式从所述查询参数中匹配出需要进行查询的域名。
- 根据权利要求8所述的方法,其特征在于,所述根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀,包括:获取缓存中的域名后缀级别;根据获取的域名后缀级别,生成正则表达式,与所述需要进行查询的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果,如果不在缓存中,则令域名后缀级别减一,重新生成正则表达式,继续进行匹配,直到返回匹配结果或返回空。
- 一种获取域名后缀的装置,其特征在于,包括:缓存更新模块,用于读取配置数据,用获取到的配置数据更新缓存;后缀查询模块,用于根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀。
- 根据权利要求10所述的装置,其特征在于,所述缓存更新模块还用于在读取配置数据之后,用获取到的配置数据更新缓存之前,清除缓存。
- 根据权利要求11所述的装置,其特征在于,所述缓存更新模块还用于:在读取配置数据,用获取到的配置数据更新缓存之前,开启缓存写锁;在读取配置数据,用获取到的配置数据更新缓存之后,关闭缓存写锁。
- 根据权利要求10所述的装置,其特征在于,所述配置数据包括域名后缀及域名后缀级别。
- 根据权利要求13所述的装置,其特征在于,所述缓存更新模块在用获取到的配置数据更新缓存时,执行如下操作:对配置数据中的每个域名后缀,经过哈希计算得到对应的哈希值;将哈希值与哈希表数组长度相与,得到对应的哈希表数组位置;根据该哈希表数组位置,将该域名后缀放入哈希表中;取配置数据中所有域名后缀的最大域名后缀级别存储在缓存中。
- 根据权利要求10所述的装置,其特征在于,所述缓存更新模块定期重复读取配置数据,用获取到的配置数据更新缓存。
- 根据权利要求10所述的装置,其特征在于,所述后缀查询模块还用于:在根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀之前,开启缓存读锁;根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀 之后,关闭缓存读锁。
- 根据权利要求10所述的装置,其特征在于,所述后缀查询模块还用于通过正则表达式从所述查询参数中匹配出需要进行查询的域名。
- 根据权利要求17所述的装置,其特征在于,所述后缀查询模块在根据输入的查询参数及缓存中的域名后缀级别,在缓存中查询得到对应的域名后缀时,执行如下操作:获取缓存中的域名后缀级别;根据获取的域名后缀级别,生成正则表达式,与所述需要进行查询的域名进行匹配,在匹配后进行判断,判断匹配出的结果是否在缓存中,如果缓存命中,则返回匹配结果,如果不在缓存中,则令域名后缀级别减一,重新生成正则表达式,继续进行匹配,直到返回匹配结果或返回空。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510411936.8 | 2015-07-14 | ||
CN201510411936.8A CN106357831A (zh) | 2015-07-14 | 2015-07-14 | 一种获取域名后缀的方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2017008659A1 true WO2017008659A1 (zh) | 2017-01-19 |
Family
ID=57756846
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2016/088520 WO2017008659A1 (zh) | 2015-07-14 | 2016-07-05 | 一种获取域名后缀的方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106357831A (zh) |
WO (1) | WO2017008659A1 (zh) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110096334A (zh) * | 2019-04-19 | 2019-08-06 | 深圳前海微众银行股份有限公司 | 缓存处理方法、装置、设备及计算机可读存储介质 |
CN110109958A (zh) * | 2019-04-19 | 2019-08-09 | 深圳前海微众银行股份有限公司 | 缓存处理方法、装置、设备及计算机可读存储介质 |
CN110209701A (zh) * | 2019-06-10 | 2019-09-06 | 天津神舟通用数据技术有限公司 | 一种基于内存多级缓存的数据快速分页查询访问的方法 |
CN115982311A (zh) * | 2023-03-21 | 2023-04-18 | 广东海洋大学 | 一种链表的生成方法、装置、终端设备及存储介质 |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114598748B (zh) * | 2021-12-08 | 2024-09-27 | 北京金山云网络技术有限公司 | 缓存资源的刷新方法、装置及系统 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110010413A1 (en) * | 2009-07-09 | 2011-01-13 | International Business Machines Corporation | Tcp/ip host name resolution on a private network |
CN103023864A (zh) * | 2011-09-28 | 2013-04-03 | 中国移动通信集团公司 | 一种域名封堵方法和设备 |
CN103856569A (zh) * | 2012-11-28 | 2014-06-11 | 方正宽带网络服务股份有限公司 | 一种同步域名系统资源信息的方法及设备 |
CN104378452A (zh) * | 2013-08-14 | 2015-02-25 | 阿里巴巴集团控股有限公司 | 一种用于域名解析的方法、装置及系统 |
CN104427011A (zh) * | 2013-09-02 | 2015-03-18 | 中兴通讯股份有限公司 | 域名解析的方法、域名缓存服务器及最终域名服务器 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100355315C (zh) * | 2004-08-30 | 2007-12-12 | 华为技术有限公司 | 一种电话号码到统一资源标识映射的业务实现方法 |
EP1764973A1 (en) * | 2005-09-16 | 2007-03-21 | Advanced Digital Broadcast S.A. | Method for referencing remote element of content, method for providing content with remote elements and system for distributing content |
RU2011117608A (ru) * | 2008-10-15 | 2012-11-27 | Нокиа Корпорейшн | Способ, устройство и компьютерный программный продукт для определения сетевого интерфейса, используемого для доступа к сетевому ресурсу |
CN103957239B (zh) * | 2014-04-04 | 2015-09-09 | 北京奇虎科技有限公司 | Dns缓存信息处理方法、设备及系统 |
-
2015
- 2015-07-14 CN CN201510411936.8A patent/CN106357831A/zh active Pending
-
2016
- 2016-07-05 WO PCT/CN2016/088520 patent/WO2017008659A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110010413A1 (en) * | 2009-07-09 | 2011-01-13 | International Business Machines Corporation | Tcp/ip host name resolution on a private network |
CN103023864A (zh) * | 2011-09-28 | 2013-04-03 | 中国移动通信集团公司 | 一种域名封堵方法和设备 |
CN103856569A (zh) * | 2012-11-28 | 2014-06-11 | 方正宽带网络服务股份有限公司 | 一种同步域名系统资源信息的方法及设备 |
CN104378452A (zh) * | 2013-08-14 | 2015-02-25 | 阿里巴巴集团控股有限公司 | 一种用于域名解析的方法、装置及系统 |
CN104427011A (zh) * | 2013-09-02 | 2015-03-18 | 中兴通讯股份有限公司 | 域名解析的方法、域名缓存服务器及最终域名服务器 |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110096334A (zh) * | 2019-04-19 | 2019-08-06 | 深圳前海微众银行股份有限公司 | 缓存处理方法、装置、设备及计算机可读存储介质 |
CN110109958A (zh) * | 2019-04-19 | 2019-08-09 | 深圳前海微众银行股份有限公司 | 缓存处理方法、装置、设备及计算机可读存储介质 |
CN110209701A (zh) * | 2019-06-10 | 2019-09-06 | 天津神舟通用数据技术有限公司 | 一种基于内存多级缓存的数据快速分页查询访问的方法 |
CN115982311A (zh) * | 2023-03-21 | 2023-04-18 | 广东海洋大学 | 一种链表的生成方法、装置、终端设备及存储介质 |
CN115982311B (zh) * | 2023-03-21 | 2023-06-20 | 广东海洋大学 | 一种链表的生成方法、装置、终端设备及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN106357831A (zh) | 2017-01-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017008659A1 (zh) | 一种获取域名后缀的方法及装置 | |
US11334544B2 (en) | Method, apparatus, device and medium for storing and querying data | |
Leis et al. | The adaptive radix tree: ARTful indexing for main-memory databases | |
US20160357821A1 (en) | Dynamic pattern matching over ordered and disordered data streams | |
CN104516979B (zh) | 一种基于二次检索的数据查询方法及系统 | |
CN107729371B (zh) | 区块链的数据索引及查询方法、装置、设备及存储介质 | |
US20150100546A1 (en) | Selective Synchronization in a Hierarchical Folder Structure | |
US9037557B2 (en) | Optimistic, version number based concurrency control for index structures with atomic, non-versioned pointer updates | |
US8666981B2 (en) | Bottom-up optimistic latching method for index trees | |
US8527480B1 (en) | Method and system for managing versioned structured documents in a database | |
CN102867070A (zh) | 更新key-value分布式存储系统缓存的方法 | |
US10120916B2 (en) | In-querying data cleansing with semantic standardization | |
CN111831785B (zh) | 敏感词检测方法、装置、计算机设备及存储介质 | |
JP6982049B2 (ja) | インデックスを管理するための方法、装置、設備及び記憶媒体 | |
GB2537670A (en) | A query mediator, a method of querying a polyglot data tier and a computer program executable to carry out a method of querying a polyglot data tier | |
US20140280019A1 (en) | Systems and methods for managing data in relational database management system | |
KR20150098660A (ko) | 활성 데이터베이스 쿼리의 유지 | |
US20230315727A1 (en) | Cost-based query optimization for untyped fields in database systems | |
JP2013228999A (ja) | データベース処理装置、方法、プログラム及びデータ構造 | |
US8756246B2 (en) | Method and system for caching lexical mappings for RDF data | |
CN105915619A (zh) | 顾及访问热度的网络空间信息服务高性能内存缓存方法 | |
WO2016155510A1 (en) | Apparatus and method for creating user defined variable size tags on records in rdbms | |
US7752194B2 (en) | LDAP revision history | |
US11151178B2 (en) | Self-adapting resource aware phrase indexes | |
KR102415155B1 (ko) | 데이터 검색 장치 및 방법 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16823806 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 16823806 Country of ref document: EP Kind code of ref document: A1 |