[go: up one dir, main page]

CN117008819A - Cache writing method and device and electronic equipment - Google Patents

Cache writing method and device and electronic equipment Download PDF

Info

Publication number
CN117008819A
CN117008819A CN202211335756.2A CN202211335756A CN117008819A CN 117008819 A CN117008819 A CN 117008819A CN 202211335756 A CN202211335756 A CN 202211335756A CN 117008819 A CN117008819 A CN 117008819A
Authority
CN
China
Prior art keywords
value
target
writing
cache
variable
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
CN202211335756.2A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202211335756.2A priority Critical patent/CN117008819A/en
Publication of CN117008819A publication Critical patent/CN117008819A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The application provides a cache writing method, a device and electronic equipment, which relate to the field of data reading and writing in the field of cache, wherein the cache writing method comprises the following steps: receiving a write request, the write request being for requesting writing of a target value; updating the value of the target variable cached in the cache component to be a target cumulative value based on the target value; and writing the target cumulative value into a storage component, and setting the value of the target variable to zero. According to the cache writing method, the cache technology is applied to the writing service of the storage component, so that the number of times of writing numerical values into the storage component can be reduced, the problem that the storage component is limited by the QPS of the server can be solved, the writing pressure of the storage component is reduced, and the writing performance of the storage component is improved.

Description

Cache writing method and device and electronic equipment
Technical Field
The embodiment of the application relates to the field of data reading and writing in the field of cache, in particular to a cache writing method, a cache writing device and electronic equipment.
Background
Query-per-second (QPS) is a measure of how much traffic a particular query server handles in a specified time. For example, QPS is typically used to measure the performance of domain name system servers on the internet.
However, for the write service of the count accumulation class, the write performance of the storage component is limited by the QPS of the query server due to the high frequency of the write service. In the related art, storage is generally performed in a partition storage manner, that is, a plurality of storage components can be used to avoid the problem that a single node is limited.
However, in this manner of partition storage using multiple storage components, the writing performance of each storage component is still limited by the QPS of the server, that is, when the writing pressure of a certain storage component is too high, the writing performance of the certain storage component cannot be guaranteed.
Disclosure of Invention
The embodiment of the application provides a cache writing method, a cache writing device and electronic equipment, which can reduce the writing pressure of a storage component and further improve the writing performance of the storage component.
In a first aspect, an embodiment of the present application provides a cache writing method, including:
receiving a write request, the write request being for requesting writing of a target value;
updating the value of the target variable cached in the cache component to be a target cumulative value based on the target value;
and writing the target cumulative value into a storage component, and setting the value of the target variable to zero.
In a second aspect, an embodiment of the present application provides a cache writing device, including:
a receiving unit configured to receive a write request for requesting writing of a target value;
the updating unit is used for updating the value of the target variable cached in the cache component into a target cumulative value based on the target value;
and the writing unit is used for writing the target cumulative value into the storage component and setting the value of the target variable to be zero.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a processor adapted to implement computer instructions; the method comprises the steps of,
a computer readable storage medium storing computer instructions adapted to be loaded by a processor and to perform the method of the first aspect referred to above.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing computer instructions that, when read and executed by a processor of a computer device, cause the computer device to perform the method of the first aspect referred to above.
In a fifth aspect, embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the computer device to perform the method of the first aspect referred to above.
For the cache writing method provided by the embodiment of the application, the embodiment of the application updates the value of the target variable cached in the cache component into the target cumulative value based on the writing request, then writes the target cumulative value into the storage component, and sets the value of the target variable to zero; in other words, the number of times of writing the numerical value of the storage component can be reduced by applying the caching technology to the writing service of the storage component, so that the problem that the storage component is limited by the QPS of the server can be solved, the writing pressure of the storage component is reduced, and the writing performance of the storage component is improved.
In addition, when the target cumulative value is determined to be written into the storage component, the value of the target variable is set to be zero, so that the target variable can be accumulated again after the target cumulative value is written into the storage component, and the accuracy of the value written into the storage component is ensured.
Drawings
Fig. 1 is an example of a system framework provided by an embodiment of the present application.
Fig. 2 is a schematic flowchart of a cache writing method provided in an embodiment of the present application.
Fig. 3 is a schematic diagram of target cumulative value writing according to an embodiment of the present application.
Fig. 4 is a schematic diagram of a write request and a response message of the write request according to an embodiment of the present application.
Fig. 5 is a schematic diagram of newly created cumulative values in the case that the cumulative values are not cached in the cache module according to the embodiment of the present application.
Fig. 6 is a schematic block diagram of a buffer writing device according to an embodiment of the present application.
Fig. 7 is a schematic block diagram of an electronic device provided by an embodiment of the present application.
Detailed Description
The scheme provided by the application can relate to cloud technology.
For example, the solution provided by the present application may relate to the field of cloud storage.
Cloud storage (cloud storage) is a new concept which extends and develops in the concept of cloud computing, and a distributed cloud storage system (simply referred to as a storage system) refers to a storage system which integrates a large number of storage devices (storage devices are also called storage nodes) of different types in a network to work cooperatively through application software or application interfaces through functions of cluster application, grid technology, distributed storage file systems and the like, and provides data storage and service access functions together.
The storage method of the storage system comprises the following steps: logical volumes are created, and when logical volumes are created, each logical volume may be configured with a physical storage space, which may be a disk composition of a certain storage device or of several storage devices. The client stores data on a certain logical volume, that is, the data is stored on a file system, the file system divides the data into a plurality of parts, each part is an object, the object not only contains the data but also contains additional information such as a data Identification (ID) and the like, the file system writes each object into a physical storage space of the logical volume, and the file system records storage position information of each object, so that when the client requests to access the data, the file system can enable the client to access the data according to the storage position information of each object.
The process of configuring physical storage space for a logical volume by a storage system specifically includes: physical storage space is partitioned into stripes in advance according to the set of capacity measures for objects stored on a logical volume (which measures tend to have a large margin with respect to the capacity of the object actually to be stored) and redundant array of independent disks (RAID, redundant Array of Independent Disk), and a logical volume can be understood as a stripe, whereby physical storage space is allocated for the logical volume.
The Database (Database) can be regarded as an electronic file cabinet, namely a place for storing electronic files, and a user can perform operations such as adding, inquiring, updating, deleting and the like on data in the files. A "database" is a collection of data stored together in a manner that can be shared with multiple users, with as little redundancy as possible, independent of the application.
The database management system (Database Management System, DBMS) is a computer software system designed for managing databases, and generally has basic functions of storage, interception, security, backup, and the like. The database management system may be categorized according to the database model it supports, e.g., relational, extensible markup language (Extensible Markup Language, XML); or by the type of computer supported, e.g., server cluster, mobile phone; either by classification according to the query language used, e.g., structured query language ((Structured Query Language, SQL), XQuery), or by performance impact emphasis, e.g., maximum scale, maximum speed of operation, or by other classification means.
For another example, the scheme provided by the application can relate to the field of big data.
Big data (Big data) refers to a data set which cannot be captured, managed and processed by a conventional software tool within a certain time range, and is a massive, high-growth-rate and diversified information asset which needs a new processing mode to have stronger decision-making ability, insight discovery ability and flow optimization ability. With the rapid development of "clouds", big data has attracted more and more attention, and the big data requires special technology to effectively process a large amount of data within a tolerant elapsed time. Technologies applicable to big data include massively parallel processing databases, data mining, distributed file systems, distributed databases, cloud computing platforms, the internet, and expansion storage systems.
Fig. 1 is an example of a system framework 100 provided by an embodiment of the present application.
The system framework 100 may be an application system, and embodiments of the present application are not limited to a particular type of application. The system frame 100 includes: terminal 110, cache writing device 120, and database 130.
The terminal 110 may be at least one of a smart phone, a game console, a desktop computer, a tablet computer, an electronic book reader, an MP4 player, and a laptop portable computer. Terminal 110 may be a client that installs and runs applications. The application program may be any one of an online video program, a short video program, a picture sharing program, a sound social program, a cartoon program, a wallpaper program, a news pushing program, a supply and demand information pushing program, an academic communication program, a technical communication program, a policy communication program, a program containing a comment mechanism, a program containing a view publishing mechanism, and a knowledge sharing program. The terminals 110 may be terminals used by users, respectively, and user accounts are logged into applications running in the terminals 110.
Taking the example that the system framework 100 is a short video system, the terminal 110 may send a write request to the storage component, where the write request is for writing report data (e.g., data such as viewing duration).
However, for the write service of the count accumulation class, the write performance of the storage component is limited by the QPS of the query server due to the high frequency of the write service. In the related art, storage is generally performed in a partition storage manner, that is, a plurality of storage components can be used to avoid the problem that a single node is limited.
However, this manner of partition storage using multiple storage components does not fundamentally solve the problem, but extends the problem of single node limitation to the problem of multiple storage components limitation, and introduces new problems. For example, the partition storage mode of the plurality of storage components can raise the running cost of the server, and because the data of each storage component are not communicated, the storage component corresponding to each key is required to be additionally maintained, the mapping relation can be determined in the early stage simply through a hash and other rule mode, and the realization difficulty of operations such as capacity expansion, data migration and the like can be improved along with the increase of the storage level.
In view of this, the present application introduces the cache writing device 120, which may be used to obtain the report data (such as the data of the viewing time length) of the application program installed on the terminal 110, and cache the report data in the cache component as the cumulative value, so as to write the value of the cached variable into the storage component when the value of the cached variable meets the writing condition. In other words, the number of times of writing the numerical value of the storage component can be reduced by applying the caching technology to the writing service of the storage component, so that the problem that the storage component is limited by the QPS of the server can be solved, the writing pressure of the storage component is reduced, and the writing performance of the storage component is improved.
The cache writing device 120 may be at least one of one server, a plurality of servers, a cloud computing platform, and a virtualization center. The cache writing device 120 is used to provide background services for applications, such as the terminal 110 and applications on the terminal 110. Optionally, the cache writing means 120 takes over primary computing work and the terminal 110 takes over secondary computing work; alternatively, the cache writing device 120 takes on secondary computing work and the terminal 110 takes on primary computing work; alternatively, the terminal 110 and the cache writing device 120 perform cooperative computing by using a distributed computing architecture.
The technical scheme provided by the application will be clearly and completely described below in connection with specific embodiments.
Fig. 2 shows a schematic flow chart of a cache writing method 200 according to an embodiment of the application, which method 200 may be performed by any electronic device having data processing capabilities. For example, the electronic device may be implemented as a server. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, big data, an artificial intelligent platform and the like, which are used for providing basic cloud computing services, and the server may be directly or indirectly connected through a wired or wireless communication mode. For convenience of explanation, the cache writing method 200 is exemplified by the cache writing apparatus.
As shown in fig. 2, the method 200 may include:
s210, the cache writing device receives a writing request, wherein the writing request is used for requesting writing of a target numerical value;
The write request is illustratively a write request of the count accumulation class, or the write request may be a write request related to a high concurrency write scenario of the count accumulation class. The high concurrency writing scene of the counting accumulation class can be heartbeat accumulation of live broadcasting room watching time length, novel reading time length accumulation, task completion progress accumulation and the like.
Illustratively, the write request is for requesting an increased duration to write the target object for the target user to read or view.
For example, the target user continuously reports the write request to the cache writing device in the process of continuously reading or continuously watching the target object, so as to indicate the increasing duration of the target user for reading or watching the target object. For example, the target user reports a write request to the cache writing device every x seconds during the continuous reading or continuous viewing of the target object, where the write request is used to instruct the target user to increase the duration of reading or viewing of the target object by x seconds.
The write request may illustratively write the target value by reporting an online status (heartbeat) request.
For example, if the write request is used to indicate that the target user is in a state of reading or viewing the target object, the target value may be a default value greater than 0; if the write request indicates that the target user is not in a state of reading or viewing the target object, the target value may be directly determined to be 0.
Of course, the specific value of the target value is not limited in the embodiment of the present application.
For example, the target value may be configured by the user or may be a default value.
It should be noted that if the write request is used to request the target user to write the increased duration of reading or viewing the target object, the cache writing device needs to acquire authorization of the target user for the cache writing device before acquiring the write request in consideration of privacy protection of the user. In other words, the cache writing device acquires the write request for requesting to write the increased duration of reading or viewing the target object by the target user after acquiring the authorization of the target user for the write request by the cache writing device.
S220, the cache writing device updates the value of the target variable cached in the cache component to a target cumulative value based on the target value.
For example, if the write request is for requesting writing of an incremental length of time for the target user to read or view the target object, the target cumulative count value is used to characterize the cumulative length of time for the target user to read or view the target object.
The write request is a request based on consistent hash (hash) routing, and because the consistent hash can ensure that the request of the same user identifier is routed to the same cache write device, the write request of the same user can ensure that the values written by the request can be accumulated in the variables cached in the same cache component, and further ensure the accuracy of the value of the target variable cached in the cache component.
S230, the buffer writing device writes the target accumulated value into a storage component and sets the value of the target variable to zero.
The cache writing means may, for example, first determine whether to write the target cumulative value to the storage element, upon determining thatWhen the target cumulative value is written into the storage component, the value of the target variable is set to zero, and the target cumulative value is written into the storage component. For example, the write request is used for requesting to write the increment duration of the target user for reading or viewing the target object, and the write request is the last received request in the n requests received by the cache writing device, and assume that the values written by the requests are respectively: x is X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 After updating the value of the target variable, the updated value is not written into the storage component, but is based on X n After updating the value of the target variable, the updated value is written into the storage component, and the buffer writing device sets the value of the target variable to zero and uses the n requests to request the sum of written values (i.e. X 1 +X 2 +...+X n-1 +X n ) Writing to the storage component.
Illustratively, the value stored in the storage component is a written cumulative value, and the written cumulative value can be used for data mining application in big data, so as to support application of multi-service scenes such as service analysis, activity task analysis, data analysis and the like.
In the embodiment of the application, the cache writing device updates the value of the target variable cached in the cache component into a target cumulative value based on the writing request, then writes the target cumulative value into the storage component, and sets the value of the target variable to zero; in other words, the number of times of writing the numerical value of the storage component can be reduced by applying the caching technology to the writing service of the storage component, so that the problem that the storage component is limited by the QPS of the server can be solved, the writing pressure of the storage component is reduced, and the writing performance of the storage component is improved.
In addition, when the target cumulative value is determined to be written into the storage component, the value of the target variable is set to be zero, so that the target variable can be accumulated again after the target cumulative value is written into the storage component, and the accuracy of the value written into the storage component is ensured.
In some embodiments, the S230 may include:
when the target cumulative value meets the condition of writing the target cumulative value into the storage component, the cache writing device writes the target cumulative value into the storage component and sets the value of the target variable to zero.
In other words, the cache writing device may determine whether to write the target cumulative value to the storage element based on the target cumulative value.
The writing request is used for requesting to write the increment time of the target user for reading or watching the target object, and the writing request is the last received request in the n requests received by the cache writing device, and the values written by the requests are assumed to be respectively: x is X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 After updating the value of the target variable, the updated value is not written into the storage component, but is based on X n After updating the value of the target variable, the updated value is as follows: x is X 1 +X 2 +...+X n-1 +X n At this time, the cache writing device may be based on X 1 +X 2 +...+X n-1 +X n Determine whether or not to take X 1 +X 2 +...+X n-1 +X n Writing to the storage component.
In some embodiments, the condition is satisfied when the target cumulative value is greater than or equal to a first preset threshold value.
Illustratively, if the target cumulative value is greater than or equal to a first preset threshold value, the cache writing means determines to write the target cumulative value to the storage component; if the target cumulative value is smaller than the first preset threshold value, the cache writing device determines not to write the target cumulative value into the storage component.
In other words, the first preset threshold represents the upper threshold limit of the cumulative value.
IllustrativelyThe writing request is used for requesting to write the increasing time length of the target user for reading or watching the target object, and the writing request is the last received request in the n requests received by the cache writing device, and the values written by the requests are assumed to be respectively: x is X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 After updating the value of the target variable, the updated value is not written into the storage component, but is based on X n After updating the value of the target variable, the updated value is as follows: x is X 1 +X 2 +...+X n-1 +X n At this time, if X 1 +X 2 +...+X n-1 +X n Greater than or equal to the first preset threshold, then X is determined to be 1 +X 2 +...+X n-1 +X n Writing to the storage component; if X 1 +X 2 +...+X n-1 +X n Less than the first preset threshold, it is determined that X is not to be 1 +X 2 +...+X n-1 +X n Writing to the storage component.
It should be noted that the specific implementation of the first preset threshold is not limited by the present application.
For example, if the write request is for requesting an increased duration for writing the target user to read or view the target object, the first preset threshold may be a threshold for the target user or for the target object.
If the first preset threshold is a threshold for the target user, writing the value of the variable cached in the cache component for the target user into the storage component when the value of the variable cached in the cache component for the target user is greater than or equal to the first preset threshold; equivalently, the larger the first preset threshold value is, the larger the value of the variable cached in the cache component aiming at the target user is, that is, the more obvious the effect of the target user on relieving the writing pressure of the storage component is. If the first preset threshold is a threshold for the target object, writing the value of the variable cached in the cache component for the target object into the storage component when the value of the variable cached in the cache component for the target object is greater than or equal to the first preset threshold; equivalently, the larger the first preset threshold value is, the larger the value of the variable cached in the cache component aiming at the target object is, that is, the more obvious the effect of the target object on relieving the writing pressure of the storage component is.
Even, the first preset threshold may be a threshold for the target user and the target object, and when the values of the variables cached in the cache component for the target user and the target object are greater than or equal to the first preset threshold, the values of the variables cached in the cache component for the target user and the target object are written into the storage component; equivalently, the larger the first preset threshold value is, the larger the value of the variable cached in the cache component for the target user and the target object is, that is, the more obvious the effect of the target user and the target object on relieving the writing pressure of the storage component will be.
For another example, if the writing request is used for requesting to write the increasing duration of the target user for reading or viewing the target object, the first preset threshold may be a threshold configured by the target user, or may be a threshold configured by a manager of the cache writing device.
For another example, the buffer writing device may determine the first preset threshold according to the auxiliary information. The auxiliary information includes, but is not limited to: and determining the first preset threshold according to the business scenario corresponding to the writing request, the architecture of the storage component and the QPS of the storage component. Optionally, if the writing request is used for requesting to write the added duration of reading or viewing the target object by the target user, the service scenario corresponding to the writing request may be determined based on the target object. Optionally, the architecture of the storage component includes, but is not limited to, information such as the number of storage components. Alternatively, the QPS of the storage component may be the QPS of the write service provided by the storage component.
Even further, the auxiliary information may also include the performance of the buffer writing device and the QPS of the service layer. Optionally, the performance of the buffer writing device includes, but is not limited to, parameters such as a memory of the buffer writing device, and optionally, the QPS of the service layer includes a QPS of a device for sending the write request or a QPS of the buffer writing device. For example, if the auxiliary information includes the memory of the cache writing device, the first preset threshold may be set to be greater than the fourth preset threshold when the memory of the cache writing device is greater than the third preset threshold, and the first preset threshold may be set to be less than or equal to the fourth preset threshold when the memory of the cache writing device is less than or equal to the third preset threshold, and the third preset threshold is greater than the fourth preset threshold.
In some embodiments, the S230 may include:
when the caching duration of the target cumulative value meets the condition of writing the target cumulative value into the storage component, the caching writing device writes the target cumulative value into the storage component and sets the value of the target variable to zero.
In other words, the cache writing device may determine whether to write the target cumulative value to the storage element based on the cache duration of the target cumulative value.
The cache time period may be a time period between a current time and an update time of the target cumulative value, for example.
For example, the current time may be a timer controlled time. That is, the cache time period may be a time period between a time point when the timer times out and an update time point of the target cumulative value. Furthermore, the buffer writing device can restart the timer after updating the value of the target variable each time.
The current time may be, for example, a scanning time. That is, the buffer writing device may trigger the buffer writing device to determine whether the buffer duration is greater than or equal to the second preset threshold based on the scan mode. For example, the buffer writing device may determine whether the buffer duration is greater than or equal to the second preset threshold by means of scanning based on a timer. For example, if the timer expires, the cache writing device scans whether the cache duration is greater than or equal to the second preset threshold. Furthermore, the buffer writing device can restart the timer after updating the value of the target variable each time.
In some embodiments, the condition is satisfied when the cache time period is greater than or equal to a second preset threshold.
Illustratively, if the cache time period is greater than or equal to a second preset threshold, the cache writing means determines to write the target cumulative value to the storage component; if the cache duration is less than the second preset threshold, the cache writing device determines not to write the target cumulative value into the storage component.
In other words, the second preset threshold represents an upper threshold limit of the cache duration of the target cumulative value.
For example, assuming that the cache duration may be a duration between a current time and an update time of the target cumulative value, if the current time is N and the update time of the target variable is M, the cache writing device calculates a time difference between N and M, and if the time difference is greater than or equal to the second preset threshold, the cache writing device determines to write the target cumulative value into the storage component; if the time difference is smaller than the second preset threshold value, the cache writing device determines not to write the target cumulative value into the storage component.
In this embodiment, the second preset threshold triggers the cache writing device to write the target cumulative value into the storage component, so that accuracy, instantaneity and reliability of the value stored in the storage component can be ensured even in a scenario where the operation of the target user is discontinuous (for example, only the target object 50s is read or watched within 5 min).
It should be noted that the specific implementation of the second preset threshold is not limited by the present application.
For example, if the write request is for requesting an increased duration for writing the target user to read or view the target object, the second preset threshold may be a threshold for the target user or for the target object.
If the second preset threshold is a threshold for the target user, writing the value of the variable cached in the cache component for the target user into the storage component when the value of the variable cached in the cache component for the target user is greater than or equal to the second preset threshold; equivalently, the larger the second preset threshold value is, the larger the value of the variable cached in the cache component for the target user is, that is, the more obvious the effect of the target user on relieving the writing pressure of the storage component will be. If the second preset threshold is a threshold for the target object, writing the value of the variable cached in the cache component for the target object into the storage component when the value of the variable cached in the cache component for the target object is greater than or equal to the second preset threshold; equivalently, the larger the second preset threshold value is, the larger the value of the variable cached in the cache component aiming at the target object is, that is, the more obvious the effect of the target object on relieving the writing pressure of the storage component is.
Even, the second preset threshold may be a threshold for the target user and the target object, and when the values of the variables cached in the cache component for the target user and the target object are greater than or equal to the second preset threshold, the values of the variables cached in the cache component for the target user and the target object are written into the storage component; equivalently, the larger the second preset threshold value is, the larger the values of the variables cached in the cache component for the target user and the target object are, that is, the more obvious the effect of the target user and the target object on relieving the writing pressure of the storage component will be.
For another example, if the writing request is used for requesting to write the increasing duration of the target user for reading or viewing the target object, the second preset threshold may be a threshold configured by the target user, or may be a threshold configured by a manager of the cache writing device.
For another example, the buffer writing device may determine the second preset threshold according to the auxiliary information. The auxiliary information includes, but is not limited to: and determining the second preset threshold according to the service scene corresponding to the writing request, the architecture of the storage component and the QPS of the storage component. Optionally, if the writing request is used for requesting to write the added duration of reading or viewing the target object by the target user, the service scenario corresponding to the writing request may be determined based on the target object. Optionally, the architecture of the storage component includes, but is not limited to, information such as the number of storage components. Alternatively, the QPS of the storage component may be the QPS of the write service provided by the storage component.
Even further, the auxiliary information may also include the performance of the buffer writing device and the QPS of the service layer. Optionally, the performance of the buffer writing device includes, but is not limited to, parameters such as a memory of the buffer writing device, and optionally, the QPS of the service layer includes a QPS of a device for sending the write request or a QPS of the buffer writing device. For example, if the auxiliary information includes the memory of the cache writing device, the second preset threshold may be set to be greater than a sixth preset threshold when the memory of the cache writing device is greater than a fifth preset threshold, and the second preset threshold may be set to be less than or equal to the sixth preset threshold when the memory of the cache writing device is less than or equal to the fifth preset threshold, and the fifth preset threshold is greater than the sixth preset threshold.
Of course, in other alternative embodiments, it may be determined by other means whether to write the target cumulative value to the storage component, as the application is not limited in detail.
For example, the cache writing device determines whether to write the target cumulative value into the storage component based on an accumulated time length of the target cumulative value, which may be a time length between an update time of the target cumulative value and a time when the value of the target variable is updated to the reference value. The reference value may be an integer less than or equal to the target cumulative value. The present application is not particularly limited thereto. Illustratively, the cache writing device may be triggered to determine whether the accumulated time period is greater than or equal to a cache time period threshold based on a polling manner. For example, the storage component polls the cache component for the target variable value. For example, the storage component polls the cache component based on a timer whether the target variable is written to its value. For example, if the timer expires, the storage component polls the cache component for the value of the target variable. Further, the storage component may restart the timer each time it polls whether to write the value of the target variable.
Fig. 3 is a schematic diagram of target cumulative value writing according to an embodiment of the present application.
As shown in fig. 3, the cache writing device may include an access layer, a logic layer, and a storage layer.
The access layer can be used for connecting and accessing a network, can be realized as a public gateway interface (Common Gateway Interface, CGI), is a specification of external programs when the Web server runs, and can expand server functions according to the programs written by the CGI. The CGI can interact with the browser and can also communicate with external data sources such as database servers through data application program interfaces (Application Programming Interface, APIs) to obtain data from the database servers. Alternatively, the access layer may be referred to as a layer for providing business services, for example, the access layer may be a layer for providing business services (e.g., receiving writing services). For example, the access layer may be configured to receive a write request for requesting writing of a target value. The storage layer may include a caching component for caching values and a storage component for storing values. The logic layer may update the value of the target variable cached in the cache element to a target cumulative value based on the target value, determine whether to write the target cumulative value to the storage element, and when determining to write the target cumulative value to the storage element, set the value of the target variable to zero and write the target cumulative value to the storage element.
When the cumulative value for the A user is not in the cache component, the write request is routed through a consistent hash (hash) and then accesses the logic layer, so that if the variable for the A user is not in the cache component, the A user can be considered as a new user. At this time, the variable of the a user can be established directly based on the user information of the a user, and it is determined that the cumulative value of the variable of the a user is not written into the storage component. Based on the fact that the variable aiming at the A user is in the cache component, whether the cumulative value of the variable of the A user is written into the storage component is determined according to whether the cumulative value of the variable of the A user meets the threshold condition of the storage component, and when the cumulative value of the variable of the A user is determined to be written into the storage component, the cumulative value of the variable of the A user is written into the storage component, and the value of the variable of the A user is set to be zero.
Wherein, whether to write the cumulative value of the variable of the A user into the storage component can be determined based on the judgment mode of the active writing and the judgment mode of the passive writing.
For the judgment mode of the active writing, the cache writing device determines whether to write the accumulated value of the variable of the A user into the storage component based on the accumulated value of the variable of the A user. For example, if the cumulative value of the variable of the a user is greater than or equal to a first preset threshold, the cache writing device determines to write the cumulative value of the variable of the a user to the storage component; if the accumulated value of the variable of the A user is smaller than the first preset threshold value, the cache writing device determines that the accumulated value of the variable of the A user is not stored in the storage component. In other words, the first preset threshold represents an upper threshold limit of the cumulative number of variables for the a-user. For the judging mode of passive writing, the cache writing device determines whether to write the cumulative value of the variable of the A user into the storage component based on the cache duration of the cumulative value of the variable of the A user. For example, if the cache time length is greater than or equal to a second preset threshold, the cache writing device determines to write the cumulative value of the variable of the a user into the storage component; and if the caching duration is smaller than the second preset threshold value, the caching writing device determines not to write the cumulative value of the variable of the A user into the storage component. In other words, the second preset threshold represents the upper threshold limit of the cache duration of the cumulative number of variables of the a user.
In this embodiment, by combining the active writing judgment mode with the passive writing judgment mode, even in a scenario where the operation of the user a is discontinuous (for example, only the target object 50s is read or watched within 5 min), the accuracy, instantaneity and reliability of the numerical value stored in the storage component can be ensured.
In some embodiments, the S220 may include:
the cache writing device determines the sum of the target value and the accumulated value of the cache component aiming at the target variable as the target accumulated value; and updating the value of the target variable cached in the cache component to the target cumulative value.
For example, if the write request is for requesting to write an increment duration of reading or viewing the target object by the target user, and the write request is a last received request among n requests received by the cache writing device, it is assumed that the values written by the requests are respectively: x is X 1 、X 2 、...、X n-1 、X n The value before the cumulative value update is: x is X 1 +X 2 +...+X n-1 At this time, the buffer writing device can store the accumulated value from X 1 +X 2 +...+X n-1 The updating is as follows: x is X 1 +X 2 +...+X n-1 +X n
In some embodiments, the write request includes a first encrypted value; wherein, the S220 may include:
the buffer writing device decrypts the first encrypted value to obtain a first decrypted value; determining a sum of the first decrypted value and the target value as the target cumulative value; and then updating the value of the target variable cached in the cache component to the target cumulative value.
Illustratively, assume that the first decryption value is X d And the target value of the write request for requesting writing is: x is X n The buffer writing device may directly update the cumulative value to: x is X d +X n
In this embodiment, the cache writing device does not depend on the cache value in the cache component to update the value of the target variable, so that even in an extreme scenario that the cache value in the cache component has an error or the cache data is lost, the accuracy and reliability of the accumulated value can be ensured.
Wherein the extreme scene may include the following:
scene 1: the consistency hash is destroyed.
Since the consistency hash can ensure that the requests of the same user identifier are routed to the same cache writing device, the accumulated value of the variable cached in the cache component is meaningful. However, if the storage component needs to be scaled, the consistency hash will fail, and there is a possibility that an error exists in caching the value in the cache component.
Scene 2: the cached data is lost.
Such as a cache component crashing or crashing, resulting in a loss of cache value.
In addition, since the values used for updating the value of the target variable are all values in the write request, that is, the values used for updating the value of the target variable may exist in the interaction process of each request, the embodiment designs the values used for updating the value of the target variable as the first decryption values obtained by decrypting the first encryption values in the write request by the cache write device, so that the value updated by the cumulative value can be prevented from being maliciously utilized, and the accuracy, the safety and the reliability of the cumulative value are further ensured.
It should be noted that the decryption method of the first encrypted value is not particularly limited, in other words, any decryption method capable of decrypting the value may be used to decrypt the first encrypted value. For example, in one possible implementation, the decryption method of the first encrypted value may be a default decryption method.
In some embodiments, the method 200 may further comprise:
the buffer write device encrypts the target cumulative value to obtain a second encrypted value; and then transmitting a response message of the write request, the response message of the write request including the second encrypted value.
The write request is for requesting to write an increment time of the target user to read or view the target object, and is the last received request in the n requests received by the cache writing device, assuming that the values written by the requests are respectively:X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 、X n After updating the value of the target variable, the updated value is not written into the storage component. At this time, the second encrypted value is X 1 +X 2 +...+X n-1 +X n I.e. the buffer writing device can write data into X 1 +X 2 +...+X n-1 +X n And encrypting and obtaining the second encrypted value.
The writing request is used for requesting to write the increment time of the target user for reading or watching the target object, and the writing request is the last received request in the n requests received by the cache writing device, and the values written by the requests are assumed to be respectively: x is X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 After updating the value of the target variable, the updated value is not written into the storage component, but is based on X n After updating the value of the target variable, the updated value is written into the storage component, and the buffer writing device sets the value of the target variable to zero and uses the n requests to request the sum of written values (i.e. X 1 +X 2 +...+X n-1 +X n ) Writing to the storage component. At this time, the second encryption value is 0, that is, the buffer writing device may encrypt 0 and obtain the second encryption value.
It is to be noted that the encryption method of encrypting the target cumulative value of the present application is not particularly limited, in other words, the target cumulative value may be encrypted by any encryption method capable of encrypting a digital value. For example, in one possible implementation, the encryption method of the target cumulative value may be a default encryption method.
In some embodiments, the write request further includes a third encrypted value; the method 200 may further include:
the buffer writing device decrypts the third encrypted value to obtain a second decrypted value; then reading a write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component; if the second decryption value is not equal to the write accumulation value, the write accumulation value is updated to the second decryption value.
Illustratively, assuming that the cumulative number of times the target variable is written to the storage element is k, the values written to the storage element are Y 1 、Y 2 、...、Y k-1 、Y k The write-in cumulative value is Y 1 +Y 2 +...+Y k-1 +Y k . The buffer writing device decrypts the third encrypted value to obtain a second decrypted value; then read Y from the storage component 1 +Y 2 +...+Y k-1 +Y k If the second decryption value is not equal to Y 1 +Y 2 +...+Y k-1 +Y k Then Y is taken 1 +Y 2 +...+Y k-1 +Y k Updated to the write-cumulative value.
It should be noted that the decryption method of the third encrypted value is not particularly limited, in other words, any decryption method capable of decrypting the value may be used to decrypt the third encrypted value. For example, in one possible implementation, the decryption method of the third encrypted value may be a default decryption method. For another example, the decryption method of the third encrypted value may be the same as the decryption method of the first encrypted value.
Fig. 4 is a schematic diagram of a write request and a response message of the write request according to an embodiment of the present application.
As shown in fig. 4, the cache writing device may include an access layer, a logic layer, and a storage layer.
It should be understood that the description of the access layer, the logic layer, and the storage layer may refer to the description of fig. 3, and will not be repeated herein.
The write request and the response message of the write request of the present application will be mainly described with reference to fig. 4.
As shown in fig. 4, the write request includes a request field 1, a request field 2, and a transparent field Z1.
The request field 1 and the request field 2 may carry information such as a target value, a user identifier corresponding to the target value, and a service identifier corresponding to the target value, where the target value is requested to be written by the write request. The transparent field Z1 may be used to carry a first encrypted value. Based on the first encryption value, the buffer writing device decrypts the first encryption value to obtain a first decryption value; and then determining the sum of the first decryption value and the target value as the target cumulative value. In addition, the buffer write device encrypts the target cumulative value to obtain a second encrypted value; and then transmitting a response message of the write request, the response message of the write request including the second encrypted value. For example, the second encrypted value is carried in the transparent field Z2.
In addition, the transparent field Z1 may be used to carry a third encrypted value, based on which the buffer writing device may further decrypt the third encrypted value to obtain a second decrypted value; then reading a write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component; if the second decryption value is not equal to the write accumulation value, the write accumulation value is updated to the second decryption value.
In this embodiment, it is considered that by placing the cumulative value and the write cumulative value in the response message of the write request (i.e. Z2), each request received by the access layer carries Z2 in the response message of the last request. In this way, even if the logic layer loses the cache data or the cache data has an error in an extreme case, it can still restore the cache data by requesting the carried Z, and if the carried Z is empty, it can be regarded as an empty cache. In addition, because the Z field may exist in each interaction with the client, the Z field can be prevented from being maliciously utilized by encryption processing, and further the safety and reliability of service data are ensured.
In some embodiments, the method 200 may further comprise:
the cache writing device receives a read request, wherein the read request is used for requesting to read the total accumulated value of the target variable; reading the write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component; a response message to the read request is then sent, the response message to the read request including the write-cumulative value.
Illustratively, assuming that the cumulative number of times the target variable is written to the storage element is k, the values written to the storage element are Y 1 、Y 2 、...、Y k-1 、Y k The write-in cumulative value is Y 1 +Y 2 +...+Y k-1 +Y k . That is, after the cache writing device receives the read request, the cache writing device reads Y from the storage component 1 +Y 2 +...+Y k-1 +Y k Then sends a response message to the read request, which includes Y 1 +Y 2 +...+Y k-1 +Y k
In some embodiments, the method 200 may further comprise:
the target variable is read from the cache component to be valued; the response message of the read request further includes the value of the target variable.
For example, assume that n requests received by the cache writing device are written with values of: x is X 1 、X 2 、...、X n-1 、X n If based on X 1 、X 2 、...、X n-1 、X n After updating the value of the target variable, if the updated value is not written into the storage component, the value of the target variable is X 1 +X 2 +...+X n-1 +X n . Further, assuming that the accumulated number of times the target variable is written into the storage element is k, the values written into the storage element are Y 1 、Y 2 、...、Y k-1 、Y k The write-in cumulative value is Y 1 +Y 2 +...+Y k-1 +Y k . At this time, after receiving the read request, the cache writing device transmits the read request to the device that transmitted the read requestA response message to the request comprising Y 1 +Y 2 +...+Y k-1 +Y k X is as follows 1 +X 2 +...+X n-1 +X n
For example, assume that n requests received by the cache writing device are written with values of: x is X 1 、X 2 、...、X n-1 、X n If based on X n After updating the value of the target variable, writing the updated value into the storage component, and setting the value of the target variable to 0. Further, assuming that the accumulated number of times the target variable is written into the storage element is k, the values written into the storage element are Y 1 、Y 2 、...、Y k-1 、Y k 、Y k+1 The write-in cumulative value is Y 1 +Y 2 +...+Y k-1 +Y k . At this time, after receiving the read request, the cache writing device sends a response message of the read request to the device sending the read request, which includes Y 1 +Y 2 +...+Y k-1 +Y k +Y k+1
Fig. 5 is a schematic diagram of newly created cumulative values in the case that the cumulative values are not cached in the cache module according to the embodiment of the present application.
As shown in fig. 5, the cache writing device receives a read request, where the read request may be used to request the value of the target variable, or may be used to request the total accumulated value of the target variable.
When the read request is used for requesting to read the total accumulated value of the target variable, the written accumulated value (namely, the sum of the values written into the storage component) is directly read in the scene that the real-time performance requirement of the total accumulated value is not high, and at the moment, the maximum error value between the total accumulated value and the written accumulated value does not exceed the first preset threshold value. Under the scene that the real-time performance requirement of the total cumulative value is higher, as the value of the variable cached in the cache component is not 0, the actual total cumulative value cannot be obtained only by reading the written cumulative value, so that the written cumulative value in the storage component is required to be read, and the value of the target variable in the cache component is required to be read.
For a no-cache scenario, the original operation is: if there is no target variable in the cache component, the target variable can be directly established, and the value of the target variable is updated based on the value requested to be written by the writing request, and the accumulated value of the target variable is not written into the storage component at this time. In the improved scheme, if no target variable exists in the cache component, the target variable can be directly established, a writing request is used for requesting to write a numerical value written in the storage component, and then the sum of the numerical values written in the storage component aiming at the target variable (namely, the written cumulative value Y) is read and cached in the cache component. In the subsequent reading scenario, the actual total cumulative value can be calculated through the written cumulative value for the target variable cached in the cache component and the value of the target variable cached in the cache component.
In this embodiment, by accessing the primary storage component, a value written to a target variable (i.e., Y) is read from the storage component, and then a write accumulation amount for the target variable is established based on Y, so that in a read scenario, a total accumulation value can be calculated and used as a read value in combination with a write accumulation value established for the target variable in the cache component and a value of the target variable updated in real time, so as to ensure that data read by a read request includes the value of the target variable in the cache component; in this way, the data read from the storage unit and the actual total cumulative value are not identical when the cumulative value of the target variable cache is not written to the storage unit.
In some embodiments, if the write request includes the user identifier corresponding to the target value and the service identifier corresponding to the target value, the target variable is a variable in the cache component in which the user identifier is the same as the user identifier corresponding to the target value and the service identifier is the same as the service identifier corresponding to the target value.
If the writing request is used for requesting to write the increasing duration of the target user for reading or viewing the target object, the user identifier corresponding to the target value is the user identifier of the target user, and the service identifier corresponding to the target value is the service identifier corresponding to the target object. In other words, if the write request is for requesting to write an added duration of the target user reading or viewing the target object, the target variable is a variable in the cache component having the same user identification as the user identification of the target user and the same service identification as the service identification of the target object.
In this embodiment, the target variable is designed as a variable in which the user identifier of the cache component is the same as the user identifier corresponding to the target value and the service identifier is the same as the service identifier corresponding to the target value, and the target variable can be used for performing accumulated update on the cache value of the same user in the cache component for the same service, so that the accuracy and reliability of the cache value in the cache component are ensured.
The preferred embodiments of the present application have been described in detail above with reference to the accompanying drawings, but the present application is not limited to the specific details of the embodiments described above, and various simple modifications can be made to the technical solution of the present application within the scope of the technical concept of the present application, and all the simple modifications belong to the protection scope of the present application. For example, the individual features described in the above-mentioned embodiments can be combined in any suitable manner, without contradiction, and the application will not be described in any way in any possible combination in order to avoid unnecessary repetition. As another example, any combination of the various embodiments of the present application may be made without departing from the spirit of the present application, which should also be regarded as the disclosure of the present application.
It should also be understood that, in the various method embodiments of the present application, the sequence numbers of the processes referred to above do not mean the sequence of execution, and the execution sequence of the processes should be determined by the functions and internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present application.
The method provided by the embodiment of the application is described above, and the device provided by the embodiment of the application is described below.
Fig. 6 is a schematic block diagram of a buffer writing device 300 according to an embodiment of the present application.
As shown in fig. 6, the cache writing apparatus 300 may include:
a receiving unit 310 for receiving a write request for requesting writing of a target value;
an updating unit 320, configured to update the value of the target variable cached in the cache component to a target cumulative value based on the target value;
the writing unit 330 is configured to write the target cumulative value into the storage component, and set the value of the target variable to zero.
In some embodiments, the writing unit 330 is specifically configured to:
when the target cumulative value meets the condition of writing the target cumulative value into the storage component, the cache writing device writes the target cumulative value into the storage component and sets the value of the target variable to zero.
In some embodiments, the condition is satisfied when the target cumulative value is greater than or equal to a first preset threshold value.
In some embodiments, the writing unit 330 is specifically configured to:
when the caching duration of the target cumulative value meets the condition of writing the target cumulative value into the storage component, the caching writing device writes the target cumulative value into the storage component and sets the value of the target variable to zero.
In some embodiments, the condition is satisfied when the cache time period is greater than or equal to a second preset threshold. In some embodiments, the updating unit 320 is specifically configured to:
determining the sum of the target value and the accumulated value of the cache component aiming at the target variable cache as the target accumulated value;
and updating the value of the target variable cached in the cache component to the target cumulative value.
In some embodiments, the write request includes a first encrypted value; the updating unit 320 is specifically configured to:
decrypting the first encrypted value to obtain a first decrypted value;
determining a sum of the first decrypted value and the target value as the target cumulative value;
and updating the value of the target variable cached in the cache component to the target cumulative value.
In some embodiments, the updating unit 320 is further configured to:
encrypting the target cumulative value to obtain a second encrypted value;
and sending a response message of the write request, wherein the response message of the write request comprises the second encrypted value.
In some embodiments, the write request further includes a third encrypted value; the writing unit 330 is further configured to:
Decrypting the third encrypted value to obtain a second decrypted value;
reading a write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component;
if the second decryption value is not equal to the write accumulation value, the write accumulation value is updated to the second decryption value.
In some embodiments, the writing unit 330 is further configured to:
receiving a read request for requesting to read a total accumulated value of the target variable;
reading the write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component;
and sending a response message of the read request, wherein the response message of the read request comprises the write cumulative value.
In some embodiments, the writing unit 330 is further configured to:
the target variable is read from the cache component to be valued; the response message of the read request further includes the value of the target variable.
In some embodiments of the present invention, in some embodiments,
if the write request includes the user identifier corresponding to the target value and the service identifier corresponding to the target value, the target variable is a variable in which the user identifier in the cache component is the same as the user identifier corresponding to the target value and the service identifier is the same as the service identifier corresponding to the target value.
It should be understood that apparatus embodiments and method embodiments may correspond with each other and that similar descriptions may refer to the method embodiments. To avoid repetition, no further description is provided here. Specifically, the cache writing device 300 may correspond to a corresponding main body in the method 200 for executing the embodiment of the present application, and each unit in the cache writing device 300 is for implementing a corresponding flow in the method 200, and for brevity, will not be described herein again.
It should be further understood that each unit in the cache writing device 300 according to the embodiment of the present application may be separately or completely combined into one or several other units, or some (some) of the units may be further split into a plurality of units with smaller functions to form a unit, which may achieve the same operation without affecting the implementation of the technical effects of the embodiment of the present application. The units referred to above are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the cache writing device 300 may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by cooperation of multiple units. According to another embodiment of the present application, the cache writing apparatus 300 according to the embodiment of the present application may be constructed by running a computer program (including a program code) capable of executing steps involved in the respective methods on a general-purpose computing device of a general-purpose computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), and the like, and the storage element, and the cache writing method 200 provided by the embodiment of the present application may be implemented. The computer program may be recorded on a computer readable storage medium, and loaded into an electronic device and executed therein to implement a corresponding method of an embodiment of the present application.
In other words, the units referred to above may be implemented in hardware, or may be implemented by instructions in software, or may be implemented in a combination of hardware and software. Specifically, each step of the method embodiment in the embodiment of the present application may be implemented by an integrated logic circuit of hardware in a processor and/or an instruction in software form, and the steps of the method disclosed in connection with the embodiment of the present application may be directly implemented as a hardware decoding processor or implemented by a combination of hardware and software in the decoding processor. Alternatively, the software may reside in a well-established storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, and the like. The storage medium is located in a memory, and the processor reads information in the memory and, in combination with its hardware, performs the steps in the method embodiments referred to above.
Fig. 7 is a schematic structural diagram of an electronic device 400 provided in an embodiment of the present application.
As shown in fig. 7, the electronic device 400 includes at least a processor 410 and a computer-readable storage medium 420. Wherein the processor 410 and the computer-readable storage medium 420 may be connected by a bus or other means. The computer readable storage medium 420 is for storing a computer program 421, the computer program 421 including computer instructions, and the processor 410 is for executing the computer instructions stored by the computer readable storage medium 420. Processor 410 is a computing core and a control core of electronic device 400 that are adapted to implement one or more computer instructions, in particular to load and execute one or more computer instructions to implement a corresponding method flow or a corresponding function.
As an example, the processor 410 may also be referred to as a central processing unit (Central Processing Unit, CPU). The processor 410 may include, but is not limited to: general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete element gate or transistor logic devices, discrete hardware components, and so forth.
By way of example, computer readable storage medium 420 may be high speed RAM memory or Non-volatile memory (Non-VolatileMemorye), such as at least one magnetic disk memory; alternatively, it may be at least one computer-readable storage medium located remotely from the aforementioned processor 410. In particular, computer-readable storage media 420 includes, but is not limited to: volatile memory and/or nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and Direct memory bus RAM (DR RAM).
As shown in fig. 7, the electronic device 400 may also include a transceiver 430.
The processor 410 may control the transceiver 430 to communicate with other devices, and in particular, may send information or data to other devices or receive information or data sent by other devices. Transceiver 430 may include a transmitter and a receiver. Transceiver 430 may further include antennas, the number of which may be one or more.
It should be appreciated that the various components in the electronic device 400 are connected by a bus system that includes a power bus, a control bus, and a status signal bus in addition to a data bus. It is noted that the electronic device 400 may be any electronic device having data processing capabilities; the computer readable storage medium 420 has stored therein first computer instructions; first computer instructions stored in computer readable storage medium 420 are loaded and executed by processor 410 to implement the corresponding steps in the method embodiments provided by the present application; in particular, the first computer instructions in the computer readable storage medium 420 are loaded by the processor 410 and perform the corresponding steps, and are not repeated here.
According to another aspect of the present application, the embodiment of the present application further provides a computer-readable storage medium (Memory), which is a Memory device in the electronic device 400, for storing programs and data. Such as computer readable storage medium 420. It is understood that the computer readable storage medium 420 herein may include a built-in storage medium in the electronic device 400, and may include an extended storage medium supported by the electronic device 400. The computer-readable storage medium provides storage space that stores an operating system of the electronic device 400. Also stored in this memory space are one or more computer instructions, which may be one or more computer programs 421 (including program code), adapted to be loaded and executed by the processor 410.
According to another aspect of the application, embodiments of the application also provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. Such as computer program 421. At this point, the data processing apparatus 400 may be a computer, the processor 410 reading the computer instructions from the computer readable storage medium 420, the processor 410 executing the computer instructions to cause the computer to perform the various methods provided in the various alternatives referred to above. In other words, when implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, runs the processes of, or implements the functions of, embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, from one website, computer, server, or data center by wired (e.g., coaxial cable, fiber optic, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
Those of ordinary skill in the art will appreciate that the elements and process steps of the examples described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
Finally, it should be noted that the above is only a specific embodiment of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about the changes or substitutions within the technical scope of the present application, and the changes or substitutions are all covered by the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (15)

1. A cache writing method, comprising:
receiving a write request, wherein the write request is used for requesting to write a target numerical value;
updating the value of the target variable cached in the cache component to be a target cumulative value based on the target value;
And writing the target cumulative value into a storage component, and setting the value of the target variable to be zero.
2. The method of claim 1, wherein writing the target cumulative value to a storage component and setting the value of the target variable to zero comprises:
and when the target cumulative value meets the condition of writing the target cumulative value into the storage component, and setting the value of the target variable to be zero.
3. The method of claim 2, wherein the condition is met when the target cumulative value is greater than or equal to a first preset threshold value.
4. The method of claim 1, wherein writing the target cumulative value to a storage component and setting the value of the target variable to zero comprises:
and when the caching duration of the target cumulative value meets the condition of writing the target cumulative value into the storage component, and setting the value of the target variable to be zero.
5. The method of claim 4, wherein the condition is met when the cache time period is greater than or equal to a second preset threshold.
6. The method according to any one of claims 1 to 5, wherein updating the value of the target variable cached in the cache element to the target cumulative value based on the target value comprises:
determining the sum of the target numerical value and the accumulated value of the cache component aiming at the target variable as the target accumulated value;
and updating the value of the target variable cached in the caching component into the target cumulative value.
7. The method of any one of claims 1 to 5, wherein the write request includes a first encrypted value;
wherein updating the value of the target variable cached in the cache component to the target cumulative value based on the target value includes:
decrypting the first encrypted value to obtain a first decrypted value;
determining a sum of the first decrypted value and the target value as the target cumulative value;
and updating the value of the target variable cached in the caching component into the target cumulative value.
8. The method of claim 7, wherein the method further comprises:
encrypting the target cumulative value to obtain a second encrypted value;
And sending a response message of the write request, wherein the response message of the write request comprises the second encrypted value.
9. The method of claim 7, wherein the write request further comprises a third encrypted value;
the method further comprises the steps of:
decrypting the third encrypted value to obtain a second decrypted value;
reading a write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component;
and if the second decryption value is not equal to the writing accumulated value, updating the writing accumulated value into the second decryption value.
10. The method according to any one of claims 1 to 5, further comprising:
receiving a read request for requesting to read a total accumulated value of the target variable;
reading the write accumulation value from the storage component, the write accumulation value being used to characterize a sum of accumulation values of the target variable written to the storage component;
and sending a response message of the read request, wherein the response message of the read request comprises the write cumulative value.
11. The method according to claim 10, wherein the method further comprises:
the value of the target variable read from the cache component; the response message of the read request further includes the value of the target variable.
12. The method according to any one of claims 1 to 5, wherein if the write request includes a user identifier corresponding to the target value and a service identifier corresponding to the target value, the target variable is a variable in which the user identifier in the cache component is the same as the user identifier corresponding to the target value and the service identifier is the same as the service identifier corresponding to the target value.
13. A cache writing apparatus, comprising:
a receiving unit configured to receive a write request, where the write request is used to request writing of a target value;
the updating unit is used for updating the value of the target variable cached in the caching component into a target cumulative value based on the target value;
and the writing unit is used for writing the target cumulative value into the storage component and setting the value of the target variable to be zero.
14. An electronic device, comprising:
A processor adapted to execute a computer program;
a computer readable storage medium having stored therein a computer program which, when executed by the processor, implements the method of any one of claims 1 to 12.
15. A computer readable storage medium storing a computer program for causing a computer to perform the method of any one of claims 1 to 12.
CN202211335756.2A 2022-10-28 2022-10-28 Cache writing method and device and electronic equipment Pending CN117008819A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211335756.2A CN117008819A (en) 2022-10-28 2022-10-28 Cache writing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211335756.2A CN117008819A (en) 2022-10-28 2022-10-28 Cache writing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN117008819A true CN117008819A (en) 2023-11-07

Family

ID=88575047

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211335756.2A Pending CN117008819A (en) 2022-10-28 2022-10-28 Cache writing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN117008819A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118381833A (en) * 2024-06-25 2024-07-23 腾讯科技(深圳)有限公司 Traffic compression method and device and related equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118381833A (en) * 2024-06-25 2024-07-23 腾讯科技(深圳)有限公司 Traffic compression method and device and related equipment

Similar Documents

Publication Publication Date Title
US12132835B2 (en) Encrypted file storage
US20230053443A1 (en) Encryption key management for international data residency
US20150229590A1 (en) Method, server, client, and system for releasing instant messaging key-value data
US11063922B2 (en) Virtual content repository
US12143475B2 (en) Enabling using external tenant master keys
CN112800066B (en) Index management method, related equipment and storage medium
CN117008819A (en) Cache writing method and device and electronic equipment
CN111930753A (en) Data retrieving method and device, electronic equipment and storage medium
AU2020104253A4 (en) Encryption key management for international data residency
US12248460B2 (en) Transaction processing failover
US10819508B2 (en) Encrypted communication channels for distributed database systems
US20240403269A1 (en) Techniques for deterministically routing database requests to database servers
CN116860862B (en) Front-end caching method of low-code platform and related equipment
CN117390078B (en) Data processing method, device, storage medium and computer equipment
US20240259188A1 (en) Cryptographic key migration
WO2022188270A1 (en) Data flushing method and apparatus, and storage medium
US10514961B1 (en) Enhanced cookie management for file workflows
CN115987981A (en) Block chain authority management method and device, computer equipment and storage medium
CN116126782A (en) Offline access method and device for block data, 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