CN100485611C - Session cache method based on binary balance tree - Google Patents

Session cache method based on binary balance tree Download PDF

Info

Publication number
CN100485611C
CN100485611C CNB2006100276587A CN200610027658A CN100485611C CN 100485611 C CN100485611 C CN 100485611C CN B2006100276587 A CNB2006100276587 A CN B2006100276587A CN 200610027658 A CN200610027658 A CN 200610027658A CN 100485611 C CN100485611 C CN 100485611C
Authority
CN
China
Prior art keywords
node
tree
time
expired
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CNB2006100276587A
Other languages
Chinese (zh)
Other versions
CN101089810A (en
Inventor
张继军
郑朝晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou highguard networks Polytron Technologies Inc
Original Assignee
Haijia Network Science & Technology Co Ltd Shanghai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Haijia Network Science & Technology Co Ltd Shanghai filed Critical Haijia Network Science & Technology Co Ltd Shanghai
Priority to CNB2006100276587A priority Critical patent/CN100485611C/en
Publication of CN101089810A publication Critical patent/CN101089810A/en
Application granted granted Critical
Publication of CN100485611C publication Critical patent/CN100485611C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

A Session Cache method based on binary balance tree includes using front tree to store all nodes generated at former time slot and using back tree to store all nodes generated at later time slot, judging whether all nodes stored on said tree are expired or not by comparing ratio of said nodes setting-up time to their current time when node is searched and deleting off node stored on the tree if node stored on the tree is expired.

Description

A kind of SessionCache method based on the y-bend balanced tree
Technical field
The present invention relates to computer software technical field, relate in particular to a kind of SessionCache method, particularly a kind of SessionCache method based on the y-bend balanced tree.
Background technology
In server design, the validity that runs into various needs and time correlation through regular meeting judges that for example, effective Session that the user obtains when logining certain webpage can only in the certain hour scope effectively after surpassing certain hour, must remove.
How effectively whether Session is also effective, and invalid Session is deleted, and adopts following several modes usually:
1, Hash table (Hash table)
The mode that this mode is taked is to use index to be used as the key word of Search, thereby can find node fast, creation-time with node is kept in the node simultaneously, thereby at Search in the data that are kept at node, can judge the validity (mainly being time validity) of node, the hash algorithm seek rate is the fastest, has satisfied speed and overtime validity.But because expired node data often can't take a kind of effective method to remove (because each expired node all needs to judge by scanning, this is very inadvisable under the environment of multithreading), therefore this has piled up a large amount of useless nodes easily, thereby wastes a large amount of internal memories.
2, Adelson-Velskii-Landis tree (y-bend balanced tree)
Y-bend balanced tree AVL is a kind of at the algorithm of searching optimization, its advantage is that seek rate is very fast, simultaneously owing to the node that is the preservation existence, thereby can save internal memory most possibly, but in SessionCache used, the reason of failure node can't be effectively removed in same existence.Because Adelson-Velskii-Landis tree exists the problem that can not effectively delete failure node too, therefore deleting failure node is the very high operation of a kind of cost for Adelson-Velskii-Landis tree.
In the above-mentioned mode of mentioning, need allocate node in advance with Hash (Hash table) table mode, take a large amount of internal memories, expired node can not effectively be removed simultaneously.With Adelson-Velskii-Landis tree (y-bend balanced tree) mode then the situation that expired node can not effectively be removed can appear.So, need a kind of effective scheme to solve this problem.
Summary of the invention
The purpose of this invention is to provide a kind of SessionCache method based on the y-bend balanced tree., this method is in conjunction with the characteristics of Adelson-Velskii-Landis tree, with solving in server, the problem that the expired node that the validity judgement owing to free restriction that often runs into causes can not effectively be deleted.
Purpose of the present invention can be achieved through the following technical solutions:
A kind of SessionCache method based on the y-bend balanced tree, this method is to adopt the binary tree more than at least two to preserve node, according to the time as node, the node of all preservations of whole SessionCache is divided into more than two sections according to the time period at least, preserve all nodes that generate in the previous time period on last the tree, preserved all nodes that back a period of time generates on the back one tree; When searching node, go up to preserve the creation-time of node and the ratio between the current time by all trees relatively, judge whether the node of the preservation on all trees is expired, if the node of preserving on certain tree is expired, then deletes the node of preserving on this tree and get final product.
Beneficial effect of the present invention is: it is fast that the inventive method is effectively searched data in conjunction with Adelson-Velskii-Landis tree, effectively utilizes the characteristics of internal memory, abandoned binary tree simultaneously and deleted the wherein low shortcoming of node efficiency, thereby reached the requirement of speed and efficient combination.Need search all trees when the present invention searches, because effectively node may be positioned on all trees, when finding node, the inventive method can accurately judge whether this node is expired in conjunction with the creation-time and the current time of node.For expired node, also only need node is made marks and need not to do any tree deletion node processing, because to setting after date, its can be automatically along with the deletion of setting is deleted automatically.Because Adelson-Velskii-Landis tree has characteristics, it is equally very efficient to delete whole tree, and therefore, method of the present invention has been saved a large amount of internal memories.
Description of drawings
Fig. 1 represents that the Timeout time is 5 minutes Session Tree structural representation.
Embodiment
For technological means, creation characteristic that the present invention is realized, reach purpose and effect is easy to understand, below in conjunction with embodiment, further set forth the present invention.
A kind of SessionCache method based on the y-bend balanced tree, this method is to adopt two binary trees to preserve node, according to the time as node, the node of all preservations of whole SessionCache is divided into two sections according to the time period, preserve all nodes that generate in the previous time period on first tree, preserved all nodes that back a period of time generates on the back one tree; For example: the expired time of supposing whole SessionCache is 5 minutes, such one tree will have been preserved preceding 5 minutes data, after 5 minutes, data will be kept on the other one tree, so just the angle of cutting apart with the time is divided into the node of two time periods respectively on two trees, therefore, when supposing the node of generation in the 11st minute, wherein the node of preserving on tree will all be expired node (because their all generated in 0-5 minute), so only need the whole tree of deletion to get final product, Adelson-Velskii-Landis tree has characteristics, and it is equally very efficient to delete whole tree.
Therefore effectively to search data in conjunction with Adelson-Velskii-Landis tree fast for the inventive method, effectively utilizes the characteristics of internal memory, abandoned the low shortcoming of the binary tree wherein expired node efficiency of deletion simultaneously, thereby reached the requirement of speed and efficient combination.
And need search two trees when searching, because effectively node may be positioned on two trees, when finding node, can judge accurately whether this node is expired in conjunction with the creation-time of node.We also only need expired node node is made marks and need not to do any tree deletion node processing, because to setting after date, its can be automatically along with the deletion of setting is deleted automatically.
Referring to Fig. 1,, describe the embodiment of the inventive method in detail below in conjunction with accompanying drawing for better explanation the present invention.
In an embodiment, the present invention uses the structure of a SESSION_CACHE to represent this composite structure. below be exactly the composition of this structure:
typedef?struct?_SESSION_CACHE
{Avlnode?*first;
time_t first_ctime;
Avlnode *second;
time_t second_ctime;
time_t interval;
#ifdef?USEMM
int lock;
#else
pthread_mutex_t lock;
#endi}?SESSION_CACHE;
In the said procedure section, SESSION_CACHE has two members, first Tree and second Tree.Here, first is first Adelson-Velskii-Landis tree, and second is second balanced tree, and interval is the time interval, and first_ctime is the time that first tree is set up, and second_ctime is second time that tree is set up.The Timeout time is 5 minutes Session Tree structure, and Lock is the mutual exclusion lock under multithreading or multi-process environment.
Implementing to insert in the operating process of node, method of the present invention is checked the creation-time of first tree earlier, if the creation-time of first tree is also within the term of validity, that just directly is inserted into node in the first tree, and First exchanged to Second, newly-built then First tree is inserted into node in the First tree then.
If expired, then delete the second tree, because the second tree is exchanged in the past by first all, just second sets the always current first of node that preserves and sets the node of previous interval time period, and the first assignment is set to second.Below be the program language in this operation institute implementation process:
if((nowtime-(cache->first_ctime))>(cache->interval))
{ avl_free(cache->second,(AVL_FREE)eavl_free);
cache->second=cache->first;
cache->first=NULL;
cache->first_ctime=nowtime;}
After the said process end, insert newly-built node again and set to first.
Search in the operating process of node implementing, this method is looked into the first tree earlier, under the situation that the first tree node can not find out, searches for the second tree again. followingly be the program language in this operation institute implementation process:
pentry=avl_find(cache->first,&entry,eavl_compare);
if(pentry==NULL)
{?pentry=avl_find(cache->second,&entry,eavl_compare);}
if(pentry)
{?if((nowtime-pentry->last_access_time)>cache->interval)
{//?The?Node?Has?Expired
return?SEARCH_FAIL;}
else{//The?Node?In?Valid?Time,ItIs?Valid}}。
When searching node we always the creation-time and the ratio of current time of comparison node determine whether node accurately expired. owing to inserting the processing of node, therefore can not preserve too many expired node in the tree.
In sum,, do not spend performing creative labour, on the basis of the foregoing description, can do multiple variation, can realize purpose of the present invention equally for those skilled in the art.But above-mentioned various variations obviously should be in the protection domain of claims of the present invention.

Claims (1)

1, a kind of session buffer memory SessionCache method based on the y-bend balanced tree, it is characterized in that, this method is to adopt the binary tree more than at least two to preserve node, writing down time data on the preservation node of described binary tree, the node of all preservations of whole session buffer memory SessionCache was divided into respectively on two trees according to the time period, preserve all nodes that generate in the previous time period on last the tree, preserved all nodes that back a period of time generates on the back one tree; When searching node, by relatively all set the creation-time and the current time of going up the preservation node, judge whether all trees go up the preservation node expired, expired as if the node of preserving on certain tree, then only need make marks to node and need not to do any tree deletion node processing, to setting after date, node is deleted along with the deletion of tree automatically.
CNB2006100276587A 2006-06-13 2006-06-13 Session cache method based on binary balance tree Active CN100485611C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100276587A CN100485611C (en) 2006-06-13 2006-06-13 Session cache method based on binary balance tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100276587A CN100485611C (en) 2006-06-13 2006-06-13 Session cache method based on binary balance tree

Publications (2)

Publication Number Publication Date
CN101089810A CN101089810A (en) 2007-12-19
CN100485611C true CN100485611C (en) 2009-05-06

Family

ID=38943177

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100276587A Active CN100485611C (en) 2006-06-13 2006-06-13 Session cache method based on binary balance tree

Country Status (1)

Country Link
CN (1) CN100485611C (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779189B (en) * 2012-06-30 2015-01-14 北京神州泰岳软件股份有限公司 Method and system for analyzing expressions
CN103856462B (en) * 2012-12-05 2017-02-15 深圳市快播科技有限公司 Method and system for managing sessions
CN103116641B (en) * 2013-02-21 2016-05-11 新浪网技术(中国)有限公司 Obtain method and the collator of the statistics of sequence
CN105138735B (en) * 2015-07-30 2018-05-25 中山大学 A kind of clock tree synthesis method of more macroelement multi-clock chips
CN105653367A (en) * 2015-12-24 2016-06-08 北京奇虎科技有限公司 Method and device for traversing timer
CN112333297B (en) * 2017-02-15 2023-03-24 金钱猫科技股份有限公司 Method and system for obtaining terminal attributes in batch
CN109685525B (en) * 2018-11-29 2020-12-29 河海大学 Self-destructible commodity tracing information storage method based on Merkle tree

Also Published As

Publication number Publication date
CN101089810A (en) 2007-12-19

Similar Documents

Publication Publication Date Title
CN100485611C (en) Session cache method based on binary balance tree
US8412689B2 (en) Shared log-structured multi-version transactional datastore with metadata to enable melding trees
US7584204B2 (en) Fuzzy lookup table maintenance
US8386421B2 (en) Concurrency control for confluent trees
Chu et al. Triangle listing in massive networks
US10572508B2 (en) Consistent query execution in hybrid DBMS
US20160080303A1 (en) Determining topic relevance of an email thread
Shubankar et al. A frequent keyword-set based algorithm for topic modeling and clustering of research papers
US10387453B1 (en) Database views for graphs using dynamic subgraphs
US20110113052A1 (en) Query result iteration for multiple queries
CN106161193B (en) Mail processing method, device and system
CN113901279B (en) Graph database retrieval method and device
US7752181B2 (en) System and method for performing a data uniqueness check in a sorted data set
US20160275134A1 (en) Nosql database data validation
Liu et al. Mining frequent itemsets over uncertain data streams
CN104391894A (en) Method for checking and processing repeated data
JP2001282599A (en) Method and device for managing data and recording medium with data management program stored therein
Wang et al. Event Indexing and Searching for High Volumes of Event Streams in the Cloud
Haraty et al. Efficient damage assessment and recovery using fast mapping
Wang et al. Sliding window-based frequent itemsets mining over data streams using tail pointer table
Belbachir et al. The parallelization of algorithm based on partition principle for association rules discovery
Zhang et al. Collision-free spatial hash functions for structural analysis of billion-vertex chemical bond networks
Raj et al. Mining frequent temporal structures in web graph
Liao et al. A practice probability frequent pattern mining method over transactional uncertain data streams
Kaddoura Information matrix: Fighting back using a matrix

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: SUZHOU HAIJIA NETWORK TECHNOLOGY CO., LTD.

Free format text: FORMER OWNER: SHANGHAI HAIJIA NETWORK TECHNOLOGY CO., LTD.

Effective date: 20091204

C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20091204

Address after: Room C201, international science and Technology Park, 1355 Jinji Lake Road, Suzhou Industrial Park, Jiangsu, China

Patentee after: Suzhou Highguard Network Technology Co., Ltd.

Address before: Songtao Shanghai Road, Zhangjiang High Tech Park of Pudong New Area No. 563 block B room 301-302

Patentee before: Haijia Network Science & Technology Co., Ltd., Shanghai

EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20071219

Assignee: Wuxi Sidawu Electronic Technology Co., Ltd.

Assignor: Suzhou Highguard Network Technology Co., Ltd.

Contract record no.: 2013320010039

Denomination of invention: Session cache method based on binary balance tree

Granted publication date: 20090506

License type: Exclusive License

Record date: 20130320

LICC Enforcement, change and cancellation of record of contracts on the licence for exploitation of a patent or utility model
EC01 Cancellation of recordation of patent licensing contract

Assignee: Wuxi Sidawu Electronic Technology Co., Ltd.

Assignor: Suzhou Highguard Network Technology Co., Ltd.

Contract record no.: 2013320010039

Date of cancellation: 20150909

LICC Enforcement, change and cancellation of record of contracts on the licence for exploitation of a patent or utility model
C56 Change in the name or address of the patentee
CP03 Change of name, title or address

Address after: Suzhou City, Jiangsu province 215021 Suzhou Industrial Park Tinglan Lane 183, Shahu science and Technology Park building 11

Patentee after: Suzhou highguard networks Polytron Technologies Inc

Address before: 215021 C201 room, international science and Technology Park, 1355 Jinji Lake Road, Suzhou Industrial Park, Jiangsu, China

Patentee before: Suzhou Highguard Network Technology Co., Ltd.