CN114064781A - Cache mechanism-based multi-tenant data source management method and readable storage medium - Google Patents

Cache mechanism-based multi-tenant data source management method and readable storage medium Download PDF

Info

Publication number
CN114064781A
CN114064781A CN202111435270.1A CN202111435270A CN114064781A CN 114064781 A CN114064781 A CN 114064781A CN 202111435270 A CN202111435270 A CN 202111435270A CN 114064781 A CN114064781 A CN 114064781A
Authority
CN
China
Prior art keywords
tenant
data source
database
database connection
management method
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.)
Pending
Application number
CN202111435270.1A
Other languages
Chinese (zh)
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.)
Chongqing Humi Network Technology Co Ltd
Original Assignee
Chongqing Humi Network Technology Co Ltd
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 Chongqing Humi Network Technology Co Ltd filed Critical Chongqing Humi Network Technology Co Ltd
Priority to CN202111435270.1A priority Critical patent/CN114064781A/en
Publication of CN114064781A publication Critical patent/CN114064781A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the technical field of computers, in particular to a cache mechanism-based multi-tenant data source management method and a readable storage medium, wherein the method comprises the following steps: creating a database table configured with database related information corresponding to each tenant; creating a data source buffer for caching database connection corresponding to tenants; when a tenant accesses the system, database related information of a corresponding tenant is obtained from a database table, corresponding database connection is established based on the database related information, and the corresponding database connection is written into a data source buffer for caching; and when the tenant accesses the system again, the database connection of the corresponding tenant is obtained from the data source buffer, and if the corresponding database connection does not exist in the data source buffer, the previous step is returned. The multi-tenant data source management method can improve the starting speed and the running efficiency of the system, so that the effect of multi-tenant data source management can be improved.

Description

Cache mechanism-based multi-tenant data source management method and readable storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a cache mechanism-based multi-tenant data source management method and a readable storage medium.
Background
In the technical field of computer application, with the appearance of product tenant patterns and technical architectures, multi-tenant data sources need to be distinguished and isolated and managed. And forming a plurality of management models based on the isolation degree and the sharing degree, wherein different models have different trade-off choices for the sharing degree and the isolation degree. The higher the sharing degree is, the lower the tenant cost is naturally, but the higher the technical implementation difficulty is, the higher the operation and maintenance difficulty is; the isolation degree is higher, the tenant cost is naturally higher, but the technical implementation difficulty is lower, and the operation and maintenance difficulty is lower.
There are three common management models: 1) each tenant has an independent application program and a database thereof; 2) each tenant has a database; 3) has a fragmented multi-tenant database. The resource sharing degree of the three models is sequentially higher, the cost is gradually reduced, but the technical difficulty is also greatly increased. Chinese patent publication No. CN110765489A discloses "isolation method, system, electronic device, and computer storage medium for multi-tenant database", and the method includes: generating corresponding tenant information according to a renting request of a user; setting a plurality of different databases, wherein each database corresponds to a tenant and is used for storing data of the corresponding tenant; determining tenant information corresponding to the service request and providing the tenant information to the middleware; managing, by the middleware, logical relationships between the plurality of databases; databases are distinguished by data subscripts.
In the multi-tenant database isolation method in the scheme, each tenant has the database for independently storing data, the data of different tenants are completely isolated, the data security is high, and the operation efficiency and the expansibility of the database are effectively improved. However, the existing solution needs to load databases of all tenants when the system is started, and create each database connection through the connection pool. However, when the tenant does not access the system, the database connections are not used, but the system resources and the database connections are occupied all the time, which causes waste of the system resources and the number of the database connections, and results in slow system startup speed and low operation efficiency. Therefore, how to design a multi-tenant data source management method capable of improving the system starting speed and the operating efficiency is an urgent technical problem to be solved.
Disclosure of Invention
Aiming at the defects of the prior art, the technical problems to be solved by the invention are as follows: how to provide a multi-tenant data source management method capable of improving system starting speed and running efficiency, and therefore the effect of multi-tenant data source management is improved.
In order to solve the technical problems, the invention adopts the following technical scheme:
the multi-tenant data source management method based on the cache mechanism comprises the following steps:
s1: creating a database table configured with database related information corresponding to each tenant;
s2: creating a data source buffer for caching database connection corresponding to tenants;
s3: when a tenant accesses the system, database related information of a corresponding tenant is obtained from a database table, corresponding database connection is established based on the database related information, and the corresponding database connection is written into a data source buffer for caching;
s4: and when the tenant accesses the system again, acquiring the database connection of the corresponding tenant from the data source buffer, and if the corresponding database connection does not exist in the data source buffer, returning to the step S3.
Preferably, in step S1, the database related information includes the tenant identifier and the database connection address of the corresponding tenant;
in step S3, a corresponding database connection is created based on the tenant identification of the corresponding tenant and the database connection address.
Preferably, in step S2, the data source buffer is provided with a buffer validity time; and can remove from the data source buffer the database connections that have not completed reading and writing within the cache validity time.
Preferably, the multi-tenant data source management method further includes:
s5: a removal listener is created for closing the removed database connection.
Preferably, in step S2, when creating the data source buffer, the corresponding buffer switch is set, so that whether to enable the corresponding lazy loading and buffering can be selected based on the buffer switch.
The invention also discloses a computer readable storage medium, which stores a computer management program, and the steps of the cache mechanism-based multi-tenant data source management method are realized when the computer management program is executed by a processor.
Compared with the prior art, the multi-tenant data source management method has the following beneficial effects:
the invention can create database connection when the tenant accesses the system by creating the database table configured with the related information of the database, thereby solving the problem that the database of all tenants needs to be loaded and the database connection needs to be created when the system is started, and meanwhile, the problem that the system resources and the database connection number occupy can be solved by creating the database connection according to the requirement, thereby improving the starting speed of the system and further improving the effect of multi-tenant data source management. Meanwhile, the created database connection can be cached in the data source cache, so that when the tenant accesses the system again within a certain time, the tenant can directly obtain the corresponding database connection without re-creating the database connection, and the operating efficiency of the system can be improved.
Drawings
For purposes of promoting a better understanding of the objects, aspects and advantages of the invention, reference will now be made in detail to the present invention as illustrated in the accompanying drawings, in which:
fig. 1 is a logic block diagram of a multi-tenant data source management method.
Detailed Description
The following is further detailed by the specific embodiments:
the first embodiment is as follows:
the embodiment discloses a multi-tenant data source management method based on a cache mechanism.
As shown in fig. 1, the method for managing a multi-tenant data source based on a caching mechanism includes the following steps:
s1: creating a database table configured with database related information corresponding to each tenant; the database related information comprises a tenant identification code of a corresponding tenant, a database connection address, a user name and a password.
S2: and creating a data source buffer for caching the database connection corresponding to the tenant.
S3: and when the tenant accesses the system, database related information of the corresponding tenant is acquired from the database table, corresponding database connection is established based on the database related information, and the corresponding database connection is written into the data source buffer for caching. And creating a corresponding database connection based on the tenant identification code and the database connection address of the corresponding tenant.
S4: and when the tenant accesses the system again, acquiring the database connection of the corresponding tenant from the data source buffer, and if the corresponding database connection does not exist in the data source buffer, returning to the step S3.
S5: a removal listener is created for closing the removed database connection.
The invention can create database connection when the tenant accesses the system by creating the database table configured with the related information of the database, thereby solving the problem that the database of all tenants needs to be loaded and the database connection needs to be created when the system is started, and meanwhile, the problem that the system resources and the database connection number occupy can be solved by creating the database connection according to the requirement, thereby improving the starting speed of the system and further improving the effect of multi-tenant data source management. In addition, the created database connection can be cached in the data source cache, so that when the tenant accesses the system again within a certain time, the tenant can directly obtain the corresponding database connection without re-creating the database connection, and the operating efficiency of the system can be improved.
In the specific implementation process, the data source buffer is provided with effective buffering time; and can remove from the data source buffer the database connections that have not completed reading and writing within the cache validity time. Meanwhile, a removal listener for closing the removed database connection is created in step S5.
The method and the device can remove the corresponding database connection when the tenant does not access the system again after the cache effective time, so that the idle database connection can be effectively released, the number of the database connections is reduced, and the consumption and occupation of system resources are further reduced.
In a specific implementation process, when a data source buffer is created, a corresponding buffer switch is set, so that whether corresponding lazy loading and buffering are started or not can be selected based on the buffer switch.
The invention can select whether to start lazy loading and caching through the cache switch, thereby reducing hard coding and improving coding flexibility and efficiency.
In actual implementation, the embodiment uses JAVA development language, uses Spring + Mybatis + drive development framework, uses data source proxy object to obtain tenant database information source from the database, loads tenant database information into the system, creates a connection for caching when the tenant needs to use, sets expiration time of the cache, creates a connection again and caches after the connection is not loaded or expired in the cache, and accesses the database by using the development framework after obtaining the connection from the cache, thereby completing data operation.
Example two:
the present embodiment discloses a computer readable storage medium, on which a computer management program is stored, and the computer management program, when executed by a processor, implements the steps of the cache mechanism-based multi-tenant data source management method according to the present invention.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that, while the invention has been described with reference to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. Meanwhile, the detailed structures, characteristics and the like of the common general knowledge in the embodiments are not described too much. Finally, the scope of the claims should be determined by the content of the claims, and the description of the embodiments and the like in the specification should be used for interpreting the content of the claims.

Claims (6)

1. The multi-tenant data source management method based on the cache mechanism is characterized by comprising the following steps:
s1: creating a database table configured with database related information corresponding to each tenant;
s2: creating a data source buffer for caching database connection corresponding to tenants;
s3: when a tenant accesses the system, database related information of a corresponding tenant is obtained from a database table, corresponding database connection is established based on the database related information, and the corresponding database connection is written into a data source buffer for caching;
s4: and when the tenant accesses the system again, acquiring the database connection of the corresponding tenant from the data source buffer, and if the corresponding database connection does not exist in the data source buffer, returning to the step S3.
2. The multi-tenant data source management method based on the caching mechanism as claimed in claim 1, wherein: in step S1, the database related information includes the tenant identification code and the database connection address of the corresponding tenant;
in step S3, a corresponding database connection is created based on the tenant identification of the corresponding tenant and the database connection address.
3. The multi-tenant data source management method based on the caching mechanism as claimed in claim 1, wherein: in step S2, the data source buffer has a buffer valid time; and can remove from the data source buffer the database connections that have not completed reading and writing within the cache validity time.
4. The multi-tenant data source management method based on a caching mechanism of claim 3, further comprising:
s5: a removal listener is created for closing the removed database connection.
5. The multi-tenant data source management method based on the caching mechanism as claimed in claim 1, wherein: in step S2, when creating the data source buffer, the corresponding buffer switch is set, so that whether to enable the corresponding lazy loading and buffering can be selected based on the buffer switch.
6. A computer-readable storage medium, having stored thereon a computer management class program, which when executed by a processor implements the steps of the cache mechanism based multi-tenant data source management method of any one of claims 1-5.
CN202111435270.1A 2021-11-29 2021-11-29 Cache mechanism-based multi-tenant data source management method and readable storage medium Pending CN114064781A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111435270.1A CN114064781A (en) 2021-11-29 2021-11-29 Cache mechanism-based multi-tenant data source management method and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111435270.1A CN114064781A (en) 2021-11-29 2021-11-29 Cache mechanism-based multi-tenant data source management method and readable storage medium

Publications (1)

Publication Number Publication Date
CN114064781A true CN114064781A (en) 2022-02-18

Family

ID=80276972

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111435270.1A Pending CN114064781A (en) 2021-11-29 2021-11-29 Cache mechanism-based multi-tenant data source management method and readable storage medium

Country Status (1)

Country Link
CN (1) CN114064781A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401231A (en) * 2023-03-20 2023-07-07 一临云(深圳)科技有限公司 Data source management method, device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401231A (en) * 2023-03-20 2023-07-07 一临云(深圳)科技有限公司 Data source management method, device and storage medium
CN116401231B (en) * 2023-03-20 2024-04-26 一临云(深圳)科技有限公司 Data source management method, device and storage medium

Similar Documents

Publication Publication Date Title
CN107391653B (en) Distributed NewSQL database system and picture data storage method
US11663134B2 (en) Method, device and computer program product for implementing file system
US20110167239A1 (en) Methods and apparatuses for usage based allocation block size tuning
CN109710190B (en) Data storage method, device, equipment and storage medium
US20110153976A1 (en) Methods and apparatuses to allocate file storage via tree representations of a bitmap
US10275347B2 (en) System, method and computer program product for managing caches
WO2015149628A1 (en) Dns cache information processing method, device and system
US20190121541A1 (en) Method and apparatus for improving storage performance of container
US20060282481A1 (en) Implementing a tree data storage structure in a distributed environment
CN110737682A (en) cache operation method, device, storage medium and electronic equipment
CN107888687B (en) Proxy client storage acceleration method and system based on distributed storage system
CN110955655A (en) Dynamic CMDB database model storage method and system
CN114064781A (en) Cache mechanism-based multi-tenant data source management method and readable storage medium
US20200371827A1 (en) Method, Apparatus, Device and Medium for Processing Data
CN113312386B (en) Batch warehousing method based on distributed messages
US10146833B1 (en) Write-back techniques at datastore accelerators
CN115114232A (en) Method, device and medium for enumerating historical version objects
CN109358818B (en) Block device IO request processing method of data center
US20200242104A1 (en) Method and system for data handling
US11138231B2 (en) Method and system for data handling
Doekemeijer et al. Key-Value Stores on Flash Storage Devices: A Survey
CN106934044B (en) Data processing method and device
CN107967306B (en) Method for rapidly mining association blocks in storage system
CN114942727A (en) Micro-kernel file system extensible page cache system and method
CN113918603A (en) Hash cache generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination