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

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

Info

Publication number
CN112783886A
CN112783886A CN202110268927.3A CN202110268927A CN112783886A CN 112783886 A CN112783886 A CN 112783886A CN 202110268927 A CN202110268927 A CN 202110268927A CN 112783886 A CN112783886 A CN 112783886A
Authority
CN
China
Prior art keywords
event
cache
subscription
cache cleaning
cleaning
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.)
Granted
Application number
CN202110268927.3A
Other languages
Chinese (zh)
Other versions
CN112783886B (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

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/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)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a cache cleaning method, a cache cleaning device, computer equipment and a storage medium, wherein the method comprises the following steps: when the service code is detected to be executed, an observer mode is started, the subscription events are collected based on the observer mode to obtain a subscription event list, each subscription event in the subscription event list is monitored in real time, if the message of the subscription event is detected, the detected subscription event is used as a target event, the target event is intercepted in a section-oriented programming Aop mode, and cache cleaning is carried out.

Description

Cache cleaning method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a cache cleaning method and apparatus, a computer device, and a storage medium.
Background
In actual service, a database needs to be frequently accessed, in order to improve data access speed, data reading and writing are generally performed in a cache mode, so that caches are often used in multiple places, cache clearing codes and service codes are closely coupled, when cache data are accumulated to a certain amount, related operations of cache clearing are required, however, in different service processing logics, when transactions executed by the database and transactions for cache clearing are in the same transaction, concurrent operations of the caches are caused, old data cannot be thoroughly cleared, and abnormal reading and writing of the caches are easily caused.
Some current schemes clean the cache at regular time mainly through a preset strategy, and suspend the read-write operation of the cache in the cleaning process so as to avoid the above abnormal situation, which causes that part of data access is affected and the efficiency of cache cleaning is low.
Disclosure of Invention
The embodiment of the invention provides a cache cleaning method, a cache cleaning device, computer equipment and a storage medium, and aims to improve the efficiency of cache cleaning.
In order to solve the foregoing technical problem, an embodiment of the present application provides a cache cleaning method, including:
initiating an observer mode upon detecting that the business code is executed;
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 if the message of the subscription event is detected, taking the detected subscription event as a target event;
intercepting the target event by adopting a mode of facet-oriented programming Aop, and performing cache cleaning.
Optionally, the collecting the subscription events based on the observer pattern to obtain a subscription event list includes:
collecting each implementation class of the BaseEventObserver class from an IoC container as a target implementation class;
traversing each event by adopting the target implementation class, and acquiring the events related to cache cleaning as subscription events;
and storing the acquired subscription event into a subscription event list.
Optionally, the traversing each event by using the target implementation class, and acquiring the event associated with cache cleaning as the subscription event includes:
adopting the target implementation class to read the events in the event manager in sequence;
judging whether the events in the event manager contain cache cleaning instructions or not, taking the events containing the cache cleaning instructions as subscription events, and removing the cache cleaning instructions contained in the subscription events.
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 performing cache cleaning by adopting the cache cleaning class.
Optionally, the intercepting the target event and performing cache cleaning by using a tangent plane-oriented programming Aop includes:
based on a preset priority, sequencing each method corresponding to an Advisor by adopting a mode of a section-oriented programming Aop to obtain a sequencing result, and enabling the business method to be 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 clearing method, and the custom event comprises a target event;
and when the target event is detected, carrying out cache cleaning according to the sequencing result.
In order to solve the foregoing technical problem, an embodiment of the present application further provides a cache cleaning apparatus, including:
a mode starting module for starting the observer mode when detecting that the service code is 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 the message of the subscription event is detected, the detected subscription event is taken as a target event;
and the cache cleaning module is used for intercepting the target event in a way of adopting the section-oriented programming Aop and cleaning the cache.
Optionally, the event collection module includes:
the realization class collection unit is used for collecting each realization class of the BaseEventObserver class from the IoC container as a target realization class;
the event traversing unit is used for traversing each event by adopting the target implementation class, acquiring the events related to cache cleaning and taking the events as subscription events;
and the event writing unit is used for storing the acquired subscription event into a subscription event list.
Optionally, the event traversing unit includes:
the event reading subunit is used for sequentially reading the events in the event manager by adopting the target implementation class;
and 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 acquiring 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;
the initialization object unit is used for initializing the target variable into a cache object through a constructor;
a method abstraction unit, configured to abstract 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 performing cache cleaning by adopting the cache cleaning class.
Optionally, the cache cleaning module includes:
a sorting unit, configured to sort, based on a preset priority, each method corresponding to an Advisor by using a method of facet-oriented programming Aop to obtain a sorting result, so that the service method is ranked before a method corresponding to a custom event in the sorting result, where the service method is an internal transaction processing method, the custom event is an external access response event, the service method includes a cache cleaning method, and the custom event includes 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, which includes a memory, a processor, and a computer program stored in the memory and executable 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, and when the computer program is executed by a processor, the computer program implements the steps of the above cache cleaning method.
The cache cleaning method, the device, the computer equipment and the storage medium provided by the embodiment of the invention start an observer mode when detecting that a service code is executed, collect subscription events based on the observer mode to obtain a subscription event list, further monitor each subscription event in the subscription event list in real time, if a message of the subscription event is detected, use the detected subscription event as a target event, intercept the target event by adopting a mode of facing to a section programming Aop, and perform cache cleaning, so that a plurality of methods are subjected to section processing by adopting a mode of facing to a section programming Aop, the coupling among different methods is reduced, further, before the target event is detected to be executed, the target event is intercepted, the cache cleaning is preferentially performed, and when the transaction of which the cache is emptied and the transaction of which the database responds are in the same transaction, and cache cleaning exception caused by transaction concurrency is generated, and the cache cleaning efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a cache scrubbing method of the present application;
FIG. 3 is a schematic diagram of an embodiment of a cache scrubbing apparatus according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to 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 application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase 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. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
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 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like.
The terminal devices 101, 102, 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, E-book readers, MP3 players (Moving Picture E interface shows a properties Group Audio Layer III, motion Picture experts compress standard Audio Layer 3), MP4 players (Moving Picture E interface shows a properties Group Audio Layer IV, motion Picture experts compress standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
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 in the embodiment of the present application is executed by a server, and accordingly, the cache cleaning apparatus 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 needs, and the terminal devices 101, 102 and 103 in this embodiment may specifically correspond to an application system in actual production.
Referring to fig. 2, fig. 2 shows a cache cleaning method according to an embodiment of the present invention, which is described by taking the method applied to the server in fig. 1 as an example, and is detailed as follows:
s201: upon detecting that the business code is executed, the watcher mode is initiated.
Wherein the observer pattern is an object behavior pattern. It defines a one-to-many dependency relationship between objects, and when the state of an object changes, all objects dependent on it are notified and automatically updated. In the watcher model, the topic is the publisher of the notification, it does not need to know who is its watcher when it issues the notification, and there can be any number of watchers subscribing to and receiving the notification. The main effect of the observer pattern is to decouple the object, completely isolating the observer from the observed person.
In this embodiment, through the implementation class (InitializingBean) of baseeventtobserver, the places related to the cache operation are extracted as the observers, and the number of the observers may be specifically one or multiple, and is set according to the actual service requirement, which is not limited here.
The initialization method is executed when the Bean is initialized, wherein the Bean is a public Java class, and an entity for storing data generally corresponds to a table in a database. Also known as pojo, entity, domain.
The BaseEventObserver component is used for monitoring any change of any object contained in the form object and detecting the change by using the event of the element.
S202: and collecting the subscription events based on the observer mode to obtain a subscription event list.
Specifically, when the service code is started, all implementation classes of the baseeventtobserver class are collected from the IoC container, the subscription event is collected through the implementation classes of the baseeventtobserver class, a subscription event list is obtained, and meanwhile, the execution operation after the subscription event is received is set in an event notification driving mode.
In this embodiment, during startup, the class below META-INFO/spring is loaded by spring, the class related to the custom framework is configured in the file, and during startup, the class related to the custom framework is loaded into the IoC container of the service item.
Here, the subscription event in this proposal refers to an event that is interested by the observer, and since the place related to the caching operation is extracted as the observer in step S201, that is, the subscription event is an event related to the caching operation, for example, in an embodiment, the subscription event is a "member level change event", and after the event occurs, the caching is cleared.
S203: and monitoring each subscription event in the subscription event list in real time, and if the message of the subscription event is detected, taking the detected subscription event as a target event.
Specifically, each subscription event in the subscription event list is monitored in real time through an event monitoring function, and when a message of the subscription event is detected, the detected subscription event is used as a target event.
S204: and intercepting the target event by adopting a way of facet-oriented programming Aop, and cleaning the cache.
The AOP is an abbreviation of Aspect organized Programming, and refers to a technology for realizing unified maintenance of program functions by a precompilation mode and a dynamic proxy during running through facet-Oriented Programming. The AOP is a continuation of the OOP, is a hot spot in software development, is also an important content in a Spring framework, and is a derivative paradigm of functional programming. By utilizing the AOP, all parts of the business logic can be isolated, so that the coupling degree between all parts of the business logic is reduced, the reusability of a program is improved, and the development efficiency is improved.
In this embodiment, the AOP is extracted from a cut plane in the business process, and it is faced with a certain step or stage in the process to obtain the isolation effect of low coupling between parts in the logical process. Codes such as log recording, performance statistics, safety control, transaction processing, exception handling, cache cleaning and the like are divided from business logic codes, and the actions are separated and are independent to a method of non-guidance business logic, so that the codes of the business logic are not influenced when the actions are changed.
It should be noted that, in the present proposal, the AOP characteristic is adopted in Spring to sequence advisors, so as to ensure that the priority of the custom event frame is the lowest, ensure that the business method object is first proxied by the transaction, and then proxied by the custom event frame, avoid being accessed and used when the transaction log redolog is not submitted yet by cache deletion, and improve the security of data processing.
Furthermore, the proposal abstracts the relevant 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 the cache processing, and cache cleaning instructions are written in without each place needing the cache cleaning, thereby avoiding code redundancy and improving the code utilization rate.
Optionally, the main implementation process of 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 performing cache cleaning by adopting a cache cleaning class.
The preset cache cleaning instruction is a cache cleaning instruction which is pre-stored by the server according to actual needs, and 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, which is not limited herein.
In this embodiment, when it is detected that the service code is executed, an observer mode is started, subscription events are collected based on the observer mode, a subscription event list is obtained, each subscription event in the subscription event list is monitored in real time, if a message of a subscription event is detected, the detected subscription event is used as a target event, a mode of facet-oriented programming Aop is adopted to intercept the target event and perform cache cleaning, so that repeated cleaning abnormality caused by cache cleaning and concurrent cleaning when the cache is emptied and a database executes the same transaction is avoided, and cache cleaning efficiency is improved.
In some optional implementation manners of this embodiment, in step S202, collecting the subscription events based on the observer pattern, and obtaining the subscription event list includes:
collecting each implementation class of the BaseEventObserver class from an IoC container as a target implementation class;
traversing each event by adopting a target implementation class, and acquiring events related to cache cleaning as subscription events;
and storing the acquired subscription events into a subscription event list.
Specifically, each implementation class of the baseeventtobserver class is instantiated and positioned as a target implementation class through an IoC container dependence injection function, an event containing a cache cleaning operation is obtained in a traversal mode to serve as a subscription event, and each obtained subscription event is stored in a subscription event list so as to be convenient for quickly identifying and responding to the subscription event through a subscription event list in the following process.
In the embodiment, the target implementation class is acquired, the subscription events are acquired and written into the subscription event list, the subscription event acquisition efficiency is improved, and the subsequent quick identification and interception through the subscription events are facilitated.
In some optional implementations of this embodiment, the cache scrubbing method further includes storing the list of subscription events in the blockchain.
The block chain is 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, is a block chain (Blockchain) which is a decentralized database essentially and is a series of data blocks which are produced by correlation through 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 block chain can comprise a block chain bottom platform and a platform product service layer primary application service layer.
In some optional implementation manners of this embodiment, traversing each event by using the target implementation class, and acquiring an event associated with cache cleaning, as the subscription event, includes:
reading events in the event manager in sequence by adopting a target implementation class;
judging whether the events in the event manager contain cache cleaning instructions or not, taking the events containing the cache cleaning instructions as subscription events, and removing the cache cleaning instructions contained in the subscription events.
Specifically, each event in the event manager is read in sequence through the target implementation class, whether a cache cleaning instruction exists in the event is judged, the event containing the cache cleaning instruction is used as a subscription event, meanwhile, the cache cleaning instruction in the subscription event is removed, and cache cleaning processing is performed by calling a specific cache cleaning instruction in the follow-up process, so that code redundancy is avoided.
In the embodiment, the subscription event is obtained by traversing and screening the events related to the cache, so that the subsequent fast interception and cache cleaning through the subscription event are facilitated, and the cache cleaning abnormity caused by concurrent cleaning of database transactions and business methods is avoided.
In some optional implementation manners of this embodiment, in step S204, intercepting the target event in a manner of the facet-oriented programming Aop, and performing cache cleaning includes:
based on a preset priority, sequencing each method corresponding to the Advisor by adopting a mode of facing a tangent plane to program Aop to obtain a sequencing result, and enabling a service method to be arranged before a method corresponding to a user-defined event in the sequencing result, wherein the service method is an internal transaction processing method, the user-defined event is an external access response event, the service method comprises a cache clearing method, and the user-defined event comprises a target event;
and when the target event is detected, carrying out cache cleaning according to the sequencing result.
Among other things, Advisor is another implementation of a cut surface, capable of weaving notifications into target objects in a more complex manner, is an assembler that packages notifications into more complex cut surfaces. However, the Advisor can only weave the tangent plane into all target methods of the target class, and cannot weave the tangent plane into the specified target method, so in this embodiment, based on the preset priority, the Advisor is used to sequence each method in the tangent plane, so that each method is performed according to a certain sequence, thereby avoiding the exception that the transaction agent method and the custom method are concurrently processed, which results in incorrect read cache or the cache cannot be cleaned.
The Advisor is used to order each method in the section, the main steps include: taking each method as a Target object Target, adding logs before and after the Target method is executed in a log adding mode to obtain a connection point of each method, wherein the connection point refers to a definite point of the method in the execution process, such as the calling of the method or the throwing of a specific exception; determining relative points of any two methods based on the connection points of each method; for each method, determining an entry point of the method according to the relative point, wherein the position where the method is executed is called the entry point; and generating a notification corresponding to the method according to the connection point and the cut-in point of the method for each method, wherein the notification refers to an action executed on a certain specific connection point Joinpoint of the section, the notification defines the time point (executed before or after the execution of the method, and the like) and an enhanced function when another certain method is cut into the code, and the notification is packaged and the packaged notifications are sorted by combining with a preset priority to obtain a sorting result.
In this embodiment, the preset priority is that the service method takes precedence over the method corresponding to the user-defined event.
Further, when sequencing, the business method is arranged before the method corresponding to the user-defined event, so that the business method object is ensured to be executed first, and the user-defined event is executed after the business method is executed, so that the accuracy of the read cache data is ensured.
In this embodiment, by sequencing each method, priority processing of events corresponding to the business method is ensured, and an exception that the cache cannot be cleaned due to concurrent cleaning of the database for the same transaction when the cache is cleaned is avoided, which is beneficial to improving the cache cleaning efficiency.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 3 shows a schematic block diagram of a cache cleaning apparatus corresponding to the cache cleaning method in one-to-one correspondence. As shown in fig. 3, the cache scrubbing apparatus includes a mode starting module 31, an event collecting module 32, an event monitoring module 33, and a cache scrubbing module 34. The functional modules are explained in detail as follows:
a mode starting module 31, configured to start the watcher mode when detecting that the service code is executed;
an event collection module 32, configured to collect subscription events based on an observer pattern, so as to 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 of the subscription event is detected, take the detected subscription event as a target event;
and the cache cleaning module 34 is configured to intercept the target event and perform cache cleaning by using the tangent plane-oriented programming Aop.
Optionally, the event collection module 32 comprises:
the realization class collection unit is used for collecting each realization class of the BaseEventObserver class from the IoC container as a target realization class;
the event traversing unit is used for traversing each event by adopting a target implementation class, acquiring the events related to cache cleaning and taking the events as subscription events;
and the event writing unit is used for storing the acquired subscription events into the subscription event list.
Optionally, the event traversal unit includes:
the event reading subunit is used for sequentially reading the events in the event manager by adopting the target implementation class;
and 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;
the initialization object unit is used for initializing the target variable into a cache object through a constructor;
the method abstraction 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 performing cache cleaning by adopting the cache cleaning class.
Optionally, the cache cleaning module 34 includes:
the ordering unit is used for ordering each method corresponding to the Advisor by adopting a mode of face-oriented programming Aop based on a preset priority to obtain an ordering result, so that a service method is arranged in front of a method corresponding to a custom event in the ordering 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 clearing 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 apparatus further includes: and when sequencing, the business method is arranged before the method corresponding to the user-defined event.
For specific limitations of the cache cleaning device, reference may be made to the above limitations of the cache cleaning method, which are not described herein again. All or part of each module in the cache cleaning device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4, fig. 4 is a block diagram of a basic structure 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 the computer device 4 having the components connection memory 41, processor 42, network interface 43 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including a 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 memory 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 memory Card (Flash Card), and the like, which are provided on the computer device 4. Of course, the memory 41 may also include both internal and external storage devices of the computer device 4. In this embodiment, the memory 41 is generally used for storing an operating system installed in the computer device 4 and various types of application software, such as program codes for controlling electronic files. Further, the memory 41 may also 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 (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 the program code stored in the memory 41 or process data, such as program code for executing control of an electronic file.
The network interface 43 may comprise a wireless network interface or a wired network interface, and the network interface 43 is generally used for establishing communication connection between the computer device 4 and other electronic devices.
The present application further provides another embodiment, which is to provide a computer-readable storage medium, wherein the computer-readable storage medium stores an interface display program, and the interface display program is executable by at least one processor to cause the at least one processor to execute the steps of the cache cleaning method as described above.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A cache cleaning method, characterized in that the cache cleaning method comprises:
initiating an observer mode upon detecting that the business code is executed;
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 if the message of the subscription event is detected, taking the detected subscription event as a target event;
intercepting the target event by adopting a mode of facet-oriented programming Aop, and performing cache cleaning.
2. The cache cleaning method according to claim 1, wherein the collecting subscription events based on the observer pattern to obtain a list of subscription events comprises:
collecting each implementation class of the BaseEventObserver class from an IoC container as a target implementation class;
traversing each event by adopting the target implementation class, and acquiring the events related to cache cleaning as subscription events;
and storing the acquired subscription event into a subscription event list.
3. The cache cleaning method according to claim 2, wherein the traversing each event by using the target implementation class to obtain the event associated with cache cleaning as the subscription event comprises:
adopting the target implementation class to read the events in the event manager in sequence;
judging whether the events in the event manager contain cache cleaning instructions or not, taking the events containing the cache cleaning instructions as subscription events, and removing the cache cleaning instructions contained in the subscription events.
4. The cache scrubbing method according to claim 1, wherein said performing cache scrubbing 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 performing cache cleaning by adopting the cache cleaning class.
5. The cache scrubbing method according to any one of claims 1 to 4, wherein said intercepting said target event by means of facet-oriented programming Aop and performing cache scrubbing comprises:
based on a preset priority, sequencing each method corresponding to an Advisor by adopting a mode of a section-oriented programming Aop to obtain a sequencing result, and enabling the business method to be 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 clearing method, and the custom event comprises a target event;
and when the target event is detected, carrying out cache cleaning according to the sequencing result.
6. A cache cleaning apparatus, characterized in that the cache cleaning apparatus comprises:
a mode starting module for starting the observer mode when detecting that the service code is 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 the message of the subscription event is detected, the detected subscription event is taken as a target event;
and the cache cleaning module is used for intercepting the target event in a way of adopting the section-oriented programming Aop and cleaning the cache.
7. The cache scrubbing apparatus according to claim 6, wherein said event collecting module comprises:
the realization class collection unit is used for collecting each realization class of the BaseEventObserver class from the IoC container as a target realization class;
the event traversing unit is used for traversing each event by adopting the target implementation class, acquiring the events related to cache cleaning and taking the events as subscription events;
and the event writing unit is used for storing the acquired subscription event into a subscription event list.
8. The cache scrubbing apparatus according to claim 6, wherein said event traversal unit comprises:
the event reading subunit is used for sequentially reading the events in the event manager by adopting the target implementation class;
and 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.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the cache scrubbing method according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, implements the cache scrubbing method according to any one of claims 1 to 5.
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 true CN112783886A (en) 2021-05-11
CN112783886B 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 (5)

* 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
US20060218199A1 (en) * 2005-03-22 2006-09-28 International Business Machines Corporation Method and system for scrubbing data within a data storage subsystem
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

Patent Citations (5)

* 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
US20060218199A1 (en) * 2005-03-22 2006-09-28 International Business Machines Corporation Method and system for scrubbing data within a data storage subsystem
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
CN112783886B (en) 2023-08-29

Similar Documents

Publication Publication Date Title
US8220054B1 (en) Process exception list updating in a malware behavior monitoring program
CN108874624B (en) Server, method for monitoring Java process and storage medium
EP3030966B1 (en) Virtual computing instance migration
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
CN112052111B (en) Processing method, device and equipment for server abnormity early warning and storage medium
CN108874559A (en) electronic device, distributed system service link analysis method and storage medium
US9535666B2 (en) Dynamic agent delivery
CN112491602A (en) Behavior data monitoring method and device, computer equipment and medium
CN111770002A (en) Test data forwarding control method and device, readable storage medium and electronic equipment
CN115277566B (en) Load balancing method and device for data access, computer equipment and medium
US20160124829A1 (en) Agent dynamic service
US20190294796A1 (en) Resolving anomalies for network applications using code injection
CN112084486A (en) User information verification method and device, electronic equipment and storage medium
CN114095567A (en) Data access request processing method and device, computer equipment and medium
CN103440453A (en) Method for detecting operation environment of browser, client, server and system
CN111884858B (en) Equipment asset information verification method, device, system and medium
CN109189652A (en) A kind of acquisition method and system of close network terminal behavior data
CN112783886B (en) Cache cleaning method, device, computer equipment and storage medium
WO2023138923A1 (en) Failure prediction using informational logs and golden signals
CN115659045A (en) User operation identification method and device, storage medium and electronic equipment
CN115600199A (en) Security assessment method and device, electronic equipment and computer readable storage medium
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
WO2021096346A1 (en) A computer-implemented system for management of container logs and its method thereof

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