CN112783886B - Cache cleaning method, device, computer equipment and storage medium - Google Patents

Cache cleaning method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN112783886B
CN112783886B CN202110268927.3A CN202110268927A CN112783886B CN 112783886 B CN112783886 B CN 112783886B CN 202110268927 A CN202110268927 A CN 202110268927A CN 112783886 B CN112783886 B CN 112783886B
Authority
CN
China
Prior art keywords
event
cache
subscription
cache cleaning
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110268927.3A
Other languages
Chinese (zh)
Other versions
CN112783886A (en
Inventor
尹冲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202110268927.3A priority Critical patent/CN112783886B/en
Publication of CN112783886A publication Critical patent/CN112783886A/en
Application granted granted Critical
Publication of CN112783886B publication Critical patent/CN112783886B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a cache cleaning method, a device, computer equipment and a storage medium, wherein the method comprises the following steps: when the service code is detected to be executed, starting an observer mode, collecting subscription events based on the observer mode to obtain a subscription event list, further monitoring each subscription event in the subscription event list in real time, and intercepting the target event by adopting a section-oriented programming Aop mode and performing cache cleaning if the detected subscription event is used as a target event if the message of the subscription event is detected.

Description

Cache cleaning method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for cleaning a cache, a computer device, and a storage medium.
Background
In actual business, a database needs to be frequently accessed, in order to improve the data access speed, data read-write is generally performed in a cache manner, so that cache empty codes and business codes are often used in a plurality of places, the cache empty codes and the business codes are tightly coupled, and when cache data are accumulated to a certain amount, related operations of cache cleaning are needed, however, in different business processing logics, transactions executed by the database and transactions for cache cleaning are the same, and when the transactions for cache cleaning are the same, concurrent operations of cache are caused, so that old data cannot be thoroughly cleaned, and cache read-write is easy to occur abnormally.
Some current schemes mainly clear the cache at regular time through a preset strategy, and suspend the read-write operation of the cache in the clearing process so as to avoid the abnormal situation, which causes the influence of partial data access and lower efficiency of cache clearing.
Disclosure of Invention
The embodiment of the application provides a cache cleaning method, a cache cleaning device, computer equipment and a storage medium, so as to improve the cache cleaning efficiency.
In order to solve the above technical problems, an embodiment of the present application provides a cache cleaning method, including:
starting an observer mode when the execution of the service code is detected;
based on the observer mode, collecting subscription events to obtain a subscription event list;
monitoring each subscription event in the subscription event list in real time, and taking the detected subscription event as a target event if a message of the occurrence of the subscription event is detected;
and intercepting the target event by adopting a cut-plane-oriented programming Aop mode, and cleaning a cache.
Optionally, based on the observer pattern, collecting the subscription event, and obtaining the subscription event list includes:
collecting each realization class of the BaseEventObserver class from a IoC container as a target realization class;
traversing each event by adopting the target realization class, and acquiring an event associated with cache cleaning as a subscription event;
and storing the acquired subscription event into a subscription event list.
Optionally, traversing each event by adopting the target implementation class, and acquiring an event associated with cache cleaning as a subscription event, where the event comprises:
sequentially reading the events in the event manager by adopting the target implementation class;
judging whether an event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
Optionally, the performing cache cleaning includes:
acquiring a preset cache cleaning instruction, and analyzing the preset cache cleaning instruction to obtain a variable contained in the cache cleaning instruction as a target variable, wherein the cache cleaning instruction comprises a cache configuration instruction, a cache data updating instruction and a list updating instruction;
initializing the target variable into a cache object through a constructor;
abstracting the preset cache cleaning instruction into a cache method;
packaging the cache object and the cache method to obtain a cache cleaning class;
and adopting the cache cleaning class to clean the cache.
Optionally, intercepting the target event by adopting a manner of facing to the slice programming Aop, and performing cache cleaning includes:
based on a preset priority, sequencing each method corresponding to the Advisor advssor in a manner facing to the tangent plane programming Aop to obtain a sequencing result, so that in the sequencing result, the service method is arranged before a method corresponding to a custom event, wherein the service method is an internal transaction processing method, the custom event is an external access response event, the service method comprises a cache cleaning method, and the custom event comprises a target event;
and when the target event is detected, performing cache cleaning according to the sequencing result.
In order to solve the above technical problem, an embodiment of the present application further provides a cache cleaning device, including:
the mode starting module is used for starting the observer mode when the service code is detected to be executed;
the event collection module is used for collecting the subscription events based on the observer mode to obtain a subscription event list;
the event monitoring module is used for monitoring each subscription event in the subscription event list in real time, and if a message of the occurrence of the subscription event is detected, the detected subscription event is used as a target event;
and the cache cleaning module is used for intercepting the target event by adopting a cut-plane-oriented programming Aop mode and cleaning the cache.
Optionally, the event collection module includes:
an implementation class collection unit, configured to collect each implementation class of the BaseEventObserver class from the IoC container, as a target implementation class;
the event traversing unit is used for traversing each event by adopting the target implementation class, and acquiring an event associated with cache cleaning as a subscription event;
and the event writing unit is used for storing the acquired subscription event into a subscription event list.
Optionally, the event traversing unit includes:
an event reading subunit, configured to sequentially read events in an event manager by using the target implementation class;
the judging subunit is used for judging whether the event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
Optionally, the cache cleaning module further includes:
the instruction analysis unit is used for acquiring a preset cache cleaning instruction, analyzing the preset cache cleaning instruction, and obtaining a variable contained in the cache cleaning instruction as a target variable, wherein the cache cleaning instruction comprises a cache configuration instruction, a cache data updating instruction and a list updating instruction;
an initialization object unit, configured to initialize the target variable to a cache object through a constructor;
the method abstraction unit is used for abstracting the preset cache cleaning instruction into a cache method;
the packaging unit is used for packaging the cache object and the cache method to obtain a cache cleaning class;
and adopting the cache cleaning class to clean the cache.
Optionally, the cache cleaning module includes:
the ordering unit is used for ordering each method corresponding to the Advisor advssor in a way of facing to the tangent plane programming Aop based on a preset priority level to obtain an ordering result, so that the business method is arranged before the method corresponding to the custom event in the ordering result, wherein the business method is an internal transaction processing method, the custom event is an external access response event, the business method comprises a cache cleaning method, and the custom event comprises a target event;
and the cleaning unit is used for cleaning the cache according to the sequencing result when the target event is detected.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of the above cache cleaning method when executing the computer program.
In order to solve the above technical problem, an embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program implements the steps of the above cache cleaning method when executed by a processor.
According to the cache cleaning method, device, computer equipment and storage medium provided by the embodiment of the application, when the execution of the service code is detected, the observer mode is started, the subscription event list is obtained based on the observer mode, each subscription event in the subscription event list is further monitored in real time, if the message of the subscription event occurrence is detected, the detected subscription event is taken as a target event, the target event is intercepted in a manner facing to the tangent plane programming Aop, and the cache cleaning is carried out, so that the tangent planes of a plurality of methods are processed in a manner facing to the tangent plane programming Aop, the coupling between different methods is reduced, the target event is intercepted before the execution of the target event is detected, the cache cleaning is preferentially carried out, and the cache cleaning abnormality caused by the concurrency of the transaction is avoided when the transaction of cache cleaning and the transaction responded by the database is in the same transaction, and the cache cleaning efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow chart of one embodiment of a cache cleaning method of the present application;
FIG. 3 is a schematic diagram illustrating the construction of one embodiment of a cache cleaning apparatus in accordance with the present application;
FIG. 4 is a schematic structural diagram of one embodiment of a computer device in accordance with the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the applications herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having" and any variations thereof in the description of the application and the claims and the description of the drawings above are intended to cover a non-exclusive inclusion. The terms first, second and the like in the description and in the claims or in the above-described figures, are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Referring to fig. 1, as shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablet computers, electronic book readers, MP3 players (Moving Picture E interface display perts Group Audio Layer III, moving Picture expert compression standard audio layer 3), MP4 players (Moving Picture E interface display perts Group Audio Layer IV, moving Picture expert compression standard audio layer 4), laptop and desktop computers, and so on.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that, the cache cleaning method provided by the embodiment of the present application is executed by a server, and accordingly, the cache cleaning device is disposed in the server.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements, and the terminal devices 101, 102, 103 in the embodiment of the present application may specifically correspond to application systems in actual production.
Referring to fig. 2, fig. 2 shows a cache cleaning method according to an embodiment of the present application, and the method is applied to the server in fig. 1 for illustration, and is described in detail as follows:
s201: upon detecting that the business code is executed, an observer mode is initiated.
Wherein the observer pattern is an object behavior pattern. It defines a one-to-many dependency between objects, all objects that depend on an object being notified and automatically updated when the state of the object changes. In the watcher mode, the topic is the publisher of the notification, which does not need to know who is its watcher when sending the notification, and there can be any number of watchers subscribed to and receiving the notification. The primary role of the observer mode is to decouple the object, isolating the observer from the observed person completely.
In this embodiment, through the implementation class (initializing bean) of the BaseEventObserver, the places related to the cache operation are extracted into observers, where the observers may be one or multiple, and the observers may be set according to the actual service requirement, which is not limited herein.
The initialization Bean interface provides a method for initializing a Bean, and only comprises an afterPropertieset method, which is executed when the Bean is initialized, and is always a public Java class, and an entity for storing data generally corresponds to a table in a database. Also known as pojo, entity, domain.
Wherein the BaseEventObserver component is configured to monitor any changes to any object contained in the form object, and detect changes in values with events of the element.
S202: based on the observer mode, collecting the subscription events to obtain a subscription event list.
Specifically, when the service code is started, all realization classes of the BaseEventObserver class are collected from the IoC container, the subscription event is collected through the realization class of the BaseEventObserver class, a subscription event list is obtained, and meanwhile, the execution operation after the subscription event is received is set in an event notification driven mode.
The IoC container is a container with a dependency injection function, and the IoC container is responsible for instantiating, locating and configuring objects in an application program and establishing dependencies among the objects, in this embodiment, a spring will be loaded/META-INFO/spring.factor under a class at startup, a custom framework related class will be configured into the file, and a custom framework related class will be loaded into the IoC container of a service item at startup.
In this case, the subscription event refers to an event of interest to the watcher, and in step S201, the place related to the cache operation is extracted as the watcher, that is, the subscription event is an event associated with the cache operation, for example, in a specific embodiment, the subscription event is a "member level change event", and after the event occurs, cache cleaning is performed.
S203: monitoring each subscription event in the subscription event list in real time, and taking the detected subscription event as a target event if the message of the occurrence of the subscription event is detected.
Specifically, through an event monitoring function, monitoring each subscription event in the subscription event list in real time, and taking the detected subscription event as a target event when detecting the message of the occurrence of the subscription event.
S204: and intercepting the target event by adopting a cut-plane-oriented programming Aop mode, and cleaning the cache.
The AOP is an abbreviation of Aspect Oriented Programming, and refers to a technology for realizing unified maintenance of program functions by a precompiled mode and dynamic agents during running in a tangent plane programming mode. AOP is a continuation of OOP, a hotspot in software development, and an important content in Spring framework, and is a derivative model of functional programming. The AOP is utilized to isolate each part of the business logic, so that the coupling degree among the parts of the business logic is reduced, the reusability of the program is improved, and the development efficiency is improved.
In this embodiment, the AOP is extracted from a tangent plane during a service processing procedure, which is faced with a certain step or stage in the processing procedure to obtain an isolation effect with low coupling between parts in a logic procedure. Codes such as log records, performance statistics, security control, transaction processing, exception handling, cache cleaning and the like are divided from business logic codes, and the codes are independent to a method for not guiding business logic through separation of the behaviors, so that the codes which do not influence the business logic when the behaviors are changed.
It should be noted that, the present disclosure adopts the characteristic of AOP in Spring to sort advssors, so as to ensure that priority of custom event frames is lowest, ensure that business method objects will be proxied by transactions first, and finally be proxied by custom event frames, so that access and use are avoided when cache deletion is not performed yet for transaction log redox, and improve security of data processing.
Furthermore, the proposal abstracts the related operation of the cache processing into an independent cache cleaning class, when the cache processing is needed, the independent cache cleaning class is called to realize, and the cache cleaning instruction is not needed to be written into each place needing to be cleaned, thereby avoiding code redundancy and improving the code utilization rate.
Optionally, the main implementation process of cache cleaning includes:
acquiring a preset cache cleaning instruction, and analyzing the preset cache cleaning instruction to obtain a variable contained in the cache cleaning instruction as a target variable, wherein the cache cleaning instruction comprises a cache configuration instruction, a cache data updating instruction and a list updating instruction;
initializing the target variable into a cache object through a constructor;
abstracting the preset cache cleaning instruction into a cache method;
packaging the cache object and the cache method to obtain a cache cleaning class;
and adopting a cache cleaning class to carry out cache cleaning.
The preset cache cleaning instruction is a cache cleaning instruction prestored by the server according to actual needs, specifically may be an execution instruction corresponding to a third-party cache cleaning method or an execution instruction corresponding to a custom cache cleaning method, and is not limited herein.
In this embodiment, when it is detected that a service code is executed, an observer mode is started, based on the observer mode, subscription events are collected to obtain a subscription event list, and then each subscription event in the subscription event list is monitored in real time, if a message of the occurrence of a subscription event is detected, the detected subscription event is used as a target event, a manner of facing a tangent plane programming Aop is adopted to intercept the target event, and cache cleaning is performed, so that repeated cleaning abnormality caused by concurrent cleaning when cache cleaning and database execution are performed in the same transaction is avoided, and cache cleaning efficiency is improved.
In some optional implementations of the present embodiment, in step S202, collecting the subscription event based on the observer pattern, and obtaining the subscription event list includes:
collecting each realization class of the BaseEventObserver class from a IoC container as a target realization class;
traversing each event by adopting a target implementation class, and acquiring an event associated with cache cleaning as a subscription event;
and storing the acquired subscription event into a subscription event list.
Specifically, each implementation class of the baseEventObserver class is instantiated and located through a IoC container depending on an injection function, the implementation class is taken as a target implementation class, then an event containing a cache cleaning operation is acquired in a traversing mode and taken as a subscription event, and each acquired subscription event is stored in a subscription event list so that identification response can be quickly carried out on the subscription event through the subscription event list.
In the embodiment, the acquisition of the target implementation class is used for acquiring the subscription event and writing the subscription event into the subscription event list, so that the acquisition efficiency of the subscription event is improved, and the subsequent rapid identification and interception through the subscription event is facilitated.
In some optional implementations of the present embodiment, the cache cleaning method further includes storing a subscription event manifest in the blockchain.
The application refers to a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like, wherein a Blockchain (Blockchain) is an essentially decentralised database and is a series of data blocks which are generated by correlation by using a cryptography method, each data block contains information of a batch of network transactions and is used for verifying the validity of the information and generating a next block, and the Blockchain can comprise a Blockchain bottom layer platform and a platform product service layer primary application service layer.
In some optional implementations of this embodiment, traversing each event using the target implementation class, obtaining an event associated with cache cleaning as a subscription event includes:
sequentially reading the events in the event manager by adopting a target implementation class;
judging whether an event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
Specifically, through the target implementation class, each event in the event manager is read in sequence, whether a cache cleaning instruction exists in the event is judged, the event containing the cache cleaning instruction is taken as a subscription event, meanwhile, the cache cleaning instruction in the subscription event is removed, and the cache cleaning processing is carried out by calling a specific cache cleaning instruction in the follow-up process, so that code redundancy is avoided.
In this embodiment, through performing traversal screening on the events related to the cache, the subscription events are obtained, which is favorable for subsequent fast interception and cache cleaning through the subscription events, and cache cleaning abnormality caused by concurrent cleaning of database transactions and business methods is avoided.
In some optional implementations of this embodiment, in step S204, intercepting the target event by adopting a manner of facing the slice programming Aop, and performing cache cleaning includes:
based on a preset priority, sequencing each method corresponding to the Advisor advssor in a manner facing to the tangent plane programming Aop to obtain a sequencing result, so that the service method is arranged before the method corresponding to the custom event in the sequencing result, wherein the service method is an internal transaction processing method, the custom event is an external access response event, the service method comprises a cache cleaning method, and the custom event comprises a target event;
and when the target event is detected, performing cache cleaning according to the sequencing result.
The Advisor is another implementation of the cut surface, can weave notifications into target objects in a more complex manner, and is an assembler that packages the notifications into more complex cut surfaces. However, the Advisor advices can only weave the cut plane into all target methods of the target class, and cannot finish weaving the cut plane into the designated target method, so in this embodiment, each method in the cut plane is sequenced by adopting the Advisor advices based on a preset priority, so that each method is performed according to a certain sequence, and thus the problem that the read cache is incorrect or the cache cannot be cleaned is avoided due to concurrent processing of the transaction proxy method and the custom method.
Sequencing each method in the section by adopting an Advisor, wherein the main steps comprise: taking each method as a Target object, adding logs before and after the Target method is executed by adding the logs to obtain connection points of each method, wherein the connection points refer to explicit points of the method in the execution process, such as the calling of the method or the throwing of specific exceptions; determining the opposite point of any two methods based on the connection point of each method; for each method, determining an access point of the method according to the relative points of the method, wherein the execution position of the method is called the access point; for each method, generating a notification corresponding to the method according to the connection point and the access point of the method, wherein the notification refers to an action executed on a specific connection point of a tangent plane, the notification defines the time point (whether the method is executed before or after execution, etc.) and the enhancement function of the other method when the method is accessed to the code, and the packaged notification is sequenced by packaging the notification and combining with a preset priority, so as to obtain a sequencing result.
In this embodiment, the preset priority is a method corresponding to a service method in preference to a custom event.
Further, when sorting is performed, the business method is arranged before the method corresponding to the custom event, so that the business method object is ensured to be executed first, the custom event is executed after the business method is executed, and the accuracy of the read cache data is ensured.
In this embodiment, by sequencing each method, priority processing of events corresponding to the service method is ensured, and when cache cleaning is performed, the database is prevented from performing concurrent cleaning on the same transaction, so that an abnormality that the cache cannot be cleaned is caused, and cache cleaning efficiency is improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Fig. 3 shows a schematic block diagram of a cache cleaning apparatus in one-to-one correspondence with the cache cleaning method of the above embodiment. As shown in fig. 3, the cache cleaning apparatus includes a mode starting module 31, an event collecting module 32, an event monitoring module 33, and a cache cleaning module 34. The functional modules are described in detail as follows:
a mode starting module 31 for starting the observer mode when detecting that the service code is executed;
the event collection module 32 is configured to collect the subscription events based on the observer mode, and obtain a subscription event list;
the event monitoring module 33 is configured to monitor each subscription event in the subscription event list in real time, and if a message indicating occurrence of the subscription event is detected, take the detected subscription event as a target event;
the cache cleaning module 34 is configured to intercept the target event and perform cache cleaning in a manner facing to the slice programming Aop.
Optionally, the event collection module 32 includes:
an implementation class collection unit, configured to collect each implementation class of the BaseEventObserver class from the IoC container, as a target implementation class;
the event traversing unit is used for traversing each event by adopting a target implementation class, and acquiring an event associated with cache cleaning as a subscription event;
the event writing unit is used for storing the acquired subscription event into the subscription event list.
Optionally, the event traversing unit includes:
an event reading subunit, configured to sequentially read events in the event manager by using a target implementation class;
the judging subunit is used for judging whether the event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
Optionally, the cache cleaning module further includes:
the instruction analysis unit is used for acquiring a preset cache cleaning instruction, analyzing the preset cache cleaning instruction, and obtaining a variable contained in the cache cleaning instruction as a target variable, wherein the cache cleaning instruction comprises a cache configuration instruction, a cache data updating instruction and a list updating instruction;
an initialization object unit, configured to initialize a target variable to a cache object through a constructor;
the method abstract unit is used for abstracting a preset cache cleaning instruction into a cache method;
the packaging unit is used for packaging the cache object and the cache method to obtain a cache cleaning class;
and adopting the cache cleaning class to clean the cache.
Optionally, the cache cleaning module 34 includes:
the sequencing unit is used for sequencing each method corresponding to the Advisor advssor in a way of facing to the tangent plane programming Aop based on the preset priority to obtain a sequencing result, so that the service method is arranged before the method corresponding to the custom event in the sequencing result, wherein the service method is an internal transaction processing method, the custom event is an external access response event, the service method comprises a cache cleaning method, and the custom event comprises a target event;
and the cleaning unit is used for cleaning the cache according to the sequencing result when the target event is detected.
Optionally, the cache cleaning device further includes: and when sequencing is carried out, the business method is arranged before the method corresponding to the custom event.
For specific limitation of the cache cleaning device, reference may be made to the limitation of the cache cleaning method hereinabove, and the description thereof will not be repeated here. The above-mentioned each module in the buffer cleaning device may be implemented in whole or in part by software, hardware, and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In order to solve the technical problems, the embodiment of the application also provides computer equipment. Referring specifically to fig. 4, fig. 4 is a basic structural block diagram of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, a network interface 43 communicatively connected to each other via a system bus. It is noted that only a computer device 4 having a component connection memory 41, a processor 42, a network interface 43 is shown in the figures, but it is understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead. It will be appreciated by those skilled in the art that the computer device herein is a device capable of automatically performing numerical calculations and/or information processing in accordance with predetermined or stored instructions, the hardware of which includes, but is not limited to, microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASICs), programmable gate arrays (fields-Programmable Gate Array, FPGAs), digital processors (Digital Signal Processor, DSPs), embedded devices, etc.
The computer equipment can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing equipment. The computer equipment can perform man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch pad or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or D interface display memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the computer device 4. Of course, the memory 41 may also comprise both an internal memory unit of the computer device 4 and an external memory device. In this embodiment, the memory 41 is typically used for storing an operating system and various application software installed on the computer device 4, such as program codes for controlling electronic files, etc. Further, the memory 41 may be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute a program code stored in the memory 41 or process data, such as a program code for executing control of an electronic file.
The network interface 43 may comprise a wireless network interface or a wired network interface, which network interface 43 is typically used for establishing a communication connection between the computer device 4 and other electronic devices.
The present application also provides another embodiment, namely, a computer readable storage medium storing an interface display program, where the interface display program is executable by at least one processor, so that the at least one processor performs the steps of the cache cleaning method as described above.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present application.
It is apparent that the above-described embodiments are only some embodiments of the present application, but not all embodiments, and the preferred embodiments of the present application are shown in the drawings, which do not limit the scope of the patent claims. This application may be embodied in many different forms, but rather, embodiments are provided in order to provide a thorough and complete understanding of the present disclosure. Although the application has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that modifications may be made to the embodiments described in the foregoing description, or equivalents may be substituted for elements thereof. All equivalent structures made by the content of the specification and the drawings of the application are directly or indirectly applied to other related technical fields, and are also within the scope of the application.

Claims (6)

1. The cache cleaning method is characterized by comprising the following steps of:
starting an observer mode when the execution of the service code is detected;
based on the observer mode, collecting subscription events to obtain a subscription event list;
monitoring each subscription event in the subscription event list in real time, and taking the detected subscription event as a target event if a message of the occurrence of the subscription event is detected;
intercepting the target event by adopting a manner facing to the tangent plane programming Aop, and cleaning a cache;
the collecting the subscription event based on the observer mode, and obtaining a subscription event list includes:
collecting each realization class of the BaseEventObserver class from a IoC container as a target realization class;
traversing each event by adopting the target realization class, and acquiring an event associated with cache cleaning as a subscription event;
storing the acquired subscription event into a subscription event list;
traversing each event by adopting the target implementation class, and acquiring an event associated with cache cleaning as a subscription event, wherein the subscription event comprises:
sequentially reading the events in the event manager by adopting the target implementation class;
judging whether an event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
2. The cache cleaning method as recited in claim 1, wherein said performing cache cleaning comprises:
acquiring a preset cache cleaning instruction, and analyzing the preset cache cleaning instruction to obtain a variable contained in the cache cleaning instruction as a target variable, wherein the cache cleaning instruction comprises a cache configuration instruction, a cache data updating instruction and a list updating instruction;
initializing the target variable into a cache object through a constructor;
abstracting the preset cache cleaning instruction into a cache method;
packaging the cache object and the cache method to obtain a cache cleaning class;
and adopting the cache cleaning class to clean the cache.
3. The cache cleaning method as claimed in claim 1 or 2, wherein intercepting the target event by means of slice-oriented programming Aop and performing cache cleaning comprises:
based on a preset priority, sequencing each method corresponding to the Advisor advssor in a manner facing to the tangent plane programming Aop to obtain a sequencing result, so that a business method is arranged before a method corresponding to a custom event in the sequencing result, wherein the business method is an internal transaction processing method, the custom event is an external access response event, the business method comprises a cache cleaning method, and the custom event comprises a target event;
and when the target event is detected, performing cache cleaning according to the sequencing result.
4. The utility model provides a buffer memory cleaning device which characterized in that, buffer memory cleaning device includes:
the mode starting module is used for starting the observer mode when the service code is detected to be executed;
the event collection module is used for collecting the subscription events based on the observer mode to obtain a subscription event list;
the event monitoring module is used for monitoring each subscription event in the subscription event list in real time, and if a message of the occurrence of the subscription event is detected, the detected subscription event is used as a target event;
the cache cleaning module is used for intercepting the target event in a manner facing to the tangent plane programming Aop and cleaning the cache;
the event collection module includes:
an implementation class collection unit, configured to collect each implementation class of the BaseEventObserver class from the IoC container, as a target implementation class;
the event traversing unit is used for traversing each event by adopting the target implementation class, and acquiring an event associated with cache cleaning as a subscription event;
the event writing unit is used for storing the acquired subscription event into a subscription event list;
the event traversing unit includes:
an event reading subunit, configured to sequentially read events in an event manager by using the target implementation class;
the judging subunit is used for judging whether the event in the event manager contains a cache cleaning instruction, taking the event containing the cache cleaning instruction as a subscription event, and removing the cache cleaning instruction contained in the subscription event.
5. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the cache cleaning method of any one of claims 1 to 3 when the computer program is executed by the processor.
6. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements a cache cleaning method according to any one of claims 1 to 3.
CN202110268927.3A 2021-03-12 2021-03-12 Cache cleaning method, device, computer equipment and storage medium Active CN112783886B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110268927.3A CN112783886B (en) 2021-03-12 2021-03-12 Cache cleaning method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110268927.3A CN112783886B (en) 2021-03-12 2021-03-12 Cache cleaning method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112783886A CN112783886A (en) 2021-05-11
CN112783886B true CN112783886B (en) 2023-08-29

Family

ID=75762558

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110268927.3A Active CN112783886B (en) 2021-03-12 2021-03-12 Cache cleaning method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112783886B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06208445A (en) * 1993-01-08 1994-07-26 Fujitsu Ltd Data processor for executing converged display
CN110674121A (en) * 2019-08-22 2020-01-10 平安科技(深圳)有限公司 Cache data cleaning method, device, equipment and computer readable storage medium
CN111163159A (en) * 2019-12-27 2020-05-15 中国平安人寿保险股份有限公司 Message subscription method, device, server and computer readable storage medium
WO2021012562A1 (en) * 2019-07-25 2021-01-28 深圳壹账通智能科技有限公司 Blockchain data cleaning method and apparatus, computer device, and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8745011B2 (en) * 2005-03-22 2014-06-03 International Business Machines Corporation Method and system for scrubbing data within a data storage subsystem

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06208445A (en) * 1993-01-08 1994-07-26 Fujitsu Ltd Data processor for executing converged display
WO2021012562A1 (en) * 2019-07-25 2021-01-28 深圳壹账通智能科技有限公司 Blockchain data cleaning method and apparatus, computer device, and storage medium
CN110674121A (en) * 2019-08-22 2020-01-10 平安科技(深圳)有限公司 Cache data cleaning method, device, equipment and computer readable storage medium
CN111163159A (en) * 2019-12-27 2020-05-15 中国平安人寿保险股份有限公司 Message subscription method, device, server and computer readable storage medium

Also Published As

Publication number Publication date
CN112783886A (en) 2021-05-11

Similar Documents

Publication Publication Date Title
CN103201724B (en) Providing application high availability in highly-available virtual machine environments
US6643802B1 (en) Coordinated multinode dump collection in response to a fault
US9495234B1 (en) Detecting anomalous behavior by determining correlations
US10523580B2 (en) Automatic cloud provisioning based on related internet news and social network trends
CN103809967A (en) Application and data removal system
CN111770002B (en) Test data forwarding control method and device, readable storage medium and electronic equipment
CN103577328A (en) Method and device for analyzing performance of application
CN108874559A (en) electronic device, distributed system service link analysis method and storage medium
US10084637B2 (en) Automatic task tracking
CN113342472A (en) Micro-service cluster creating method and device, electronic equipment and readable storage medium
CN109408361A (en) Monkey tests restored method, device, electronic equipment and computer readable storage medium
CN112783886B (en) Cache cleaning method, device, computer equipment and storage medium
CN112416974A (en) Data processing method, device and equipment and readable storage medium
WO2023138923A1 (en) Failure prediction using informational logs and golden signals
CN112596750B (en) Application testing method and device, electronic equipment and computer readable storage medium
CN115600199A (en) Security assessment method and device, electronic equipment and computer readable storage medium
CN115499493A (en) Asynchronous transaction processing method and device, storage medium and computer equipment
CN109799981B (en) Integrated system and method based on execution chain
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN114168607A (en) Global serial number generation method, device, equipment, medium and product
CN110837433A (en) Performance optimization method and device and electronic equipment
CN116340102B (en) Memory overflow monitoring method, device, equipment and storage medium
CN116302847B (en) Dynamic acquisition method and device of abnormal information, computer equipment and medium
CN113656044B (en) Android installation package compression method and device, computer equipment and storage medium
US7536434B1 (en) Global dynamic persistent information architecture

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
GR01 Patent grant
GR01 Patent grant