CN112883307B - Cache updating method and device and social network system - Google Patents

Cache updating method and device and social network system Download PDF

Info

Publication number
CN112883307B
CN112883307B CN202110151529.3A CN202110151529A CN112883307B CN 112883307 B CN112883307 B CN 112883307B CN 202110151529 A CN202110151529 A CN 202110151529A CN 112883307 B CN112883307 B CN 112883307B
Authority
CN
China
Prior art keywords
content
cache
query result
group
predetermined
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
CN202110151529.3A
Other languages
Chinese (zh)
Other versions
CN112883307A (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.)
Shenzhen Unnoo Information Tech Co ltd
Original Assignee
Shenzhen Unnoo Information Tech Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Unnoo Information Tech Co ltd filed Critical Shenzhen Unnoo Information Tech Co ltd
Priority to CN202110151529.3A priority Critical patent/CN112883307B/en
Publication of CN112883307A publication Critical patent/CN112883307A/en
Application granted granted Critical
Publication of CN112883307B publication Critical patent/CN112883307B/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/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/01Social networking

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Resources & Organizations (AREA)
  • Computing Systems (AREA)
  • Primary Health Care (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a cache updating method, which comprises the following steps: receiving a content query request from a client, the content query request being for querying a predetermined number of content items published to a predetermined group; responding to the content query request, and querying in a cache and/or a database to obtain a target query result; and if the target query result comprises the cache query result and the database query result, storing the content items in the database query result into the cache, and adding the content identifications of the content items in the database query result to the content identification set of the preset group in the cache. The invention also discloses a corresponding cache updating device, a social networking system, a computing device and a readable storage medium.

Description

Cache updating method and device and social network system
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for updating a cache, and a social network system.
Background
With the development of network technology, group-based social networking systems are becoming increasingly popular. Users may join a group (e.g., a "community of knowledge") in a social networking system such that when an item of content is published in the group, the item of content (e.g., a "topic") will be shared with members joining the group. When a user enters or refreshes a page of a group on a client, a query is requested from a server for a newly published content item of the group so that the content item may be displayed on the group page presented after the entry or refresh.
Since requesting a query to a server for content items posted in a group, particularly recently posted content items in a group, is a high frequency operation and requires a large amount of data to be returned, a huge load pressure is imposed on databases of social networking systems, affecting query speed.
Therefore, there is a need to provide a more advanced caching scheme to reduce the frequency of access to databases and increase the query speed.
Disclosure of Invention
For this reason, the embodiment of the invention provides a cache updating method, a cache updating device and a social network system, so as to solve or at least alleviate at least one of the problems.
According to an aspect of an embodiment of the present invention, there is provided a method of updating a cache adapted to store content items published to a group and a set of content identifications of the group, the set of content identifications including content identifications of content items published to corresponding groups, the content identifications in the set of content identifications being arranged in a time order of publication of the corresponding content items, the method comprising: receiving a content query request from a client, the content query request being for querying a predetermined number of content items published to a predetermined group; responding to the content query request, and querying in a cache and/or a database to obtain a target query result; and if the target query result comprises the cache query result and the database query result, storing the content items in the database query result into the cache, and adding the content identifications of the content items in the database query result to the content identification set of the preset group in the cache.
Optionally, in the method according to the embodiment of the present invention, the query is performed in a cache and/or a database to obtain a target query result, including: inquiring a preset number of content items which are issued in a preset group and the issue time of which is positioned in a first time interval in a cache to obtain a cache inquiry result, wherein the first time interval is a time interval or a default time interval designated by a content inquiry request; comparing the number of content items in the cached query result with a predetermined number; if the number of the content items in the cache query result is smaller than the preset number, querying the database for the rest number of the content items which are published in the preset group and the published time of which is located in a second time interval, so as to obtain the database query result, wherein the second time interval is obtained based on the first time interval and the cache query result, and the rest number is the difference between the preset number and the number of the content items in the cache query result; and merging the cached query result and the database query result to obtain the target query result.
Optionally, in the method according to an embodiment of the present invention, the second time interval is obtained based on the first time interval and the buffered polling result, including: and taking the left boundary of the first time interval as the left boundary of the second time interval, and taking the earliest release time in the cache query result as the right boundary of the second time interval.
Optionally, in the method according to the embodiment of the present invention, in response to the content query request, a query is performed in a cache and/or a database to obtain a target query result, and further includes: inquiring a preset number of content items which are released in a preset group and the release time of which is positioned in a first time interval in a cache, and judging whether the cache stores a content identification set of the preset group or not; if the cache does not store the content identification set of the preset group, querying a preset number of content items which are published in the preset group and have the publication time in the first time interval in the database, and obtaining a database query result to serve as a target query result.
Optionally, in the method according to an embodiment of the present invention, if the cache does not store the content identifier set of the predetermined group, the method further includes: after obtaining the database query result as a target query result, storing content items in the database query result into a cache; and judging whether to create a content identification set of a preset group comprising the content identifications of the content items in the database query result in the cache according to the first time interval.
Optionally, in the method according to an embodiment of the present invention, determining, according to the first time interval, whether to create, in the cache, a content identifier set including a predetermined group of content identifiers of content items in the target query result includes: comparing the right boundary of the first time interval with the current time; if the right boundary of the first time interval is not earlier than the current time, creating a content identification set of a predetermined group comprising content identifications of content items in the target query result in the cache, otherwise not creating a content identification set of a predetermined group comprising content identifications of content items in the target query result in the cache.
Optionally, in the method according to an embodiment of the present invention, further includes: if the content items which are released in the preset group and the release time of which is positioned in the first time interval are not queried in the cache, querying a preset number of content items which are released in the preset group and the release time of which is positioned in the first time interval in the database, and obtaining a database query result as a target query result.
Optionally, in the method according to an embodiment of the present invention, if no content item published in the predetermined group and having a publication time within the first time interval is queried in the cache, the method further includes: after obtaining the database query result as the target query result, the content identification set of the predetermined group in the cache is not updated, and/or the content items in the database query result are stored in the cache.
Optionally, in the method according to an embodiment of the present invention, querying, in the cache, a predetermined number of content items published in a predetermined group, whose publication time is located in the first time interval, includes: querying a cache for a predetermined number of content identifiers which are published in a predetermined group and have publication times of corresponding content items located in a first time interval; and querying the corresponding content item in the cache based on the content identifier obtained by the query.
Optionally, in the method according to an embodiment of the present invention, after querying a predetermined number of content items published in a predetermined group and having a publication time located in a first time interval in the cache to obtain a cached query result, the method further includes: if the number of content items in the cached query result is equal to the preset number, or the number of content items in the cached query result is smaller than the preset number, but no content items which are published in the preset group and have the publication time in the second time interval are queried from the database, the cached query result is taken as a target query result, and the content identification set of the preset group in the cache is not updated.
Optionally, in the method according to the embodiment of the present invention, if the target query result includes a cached query result and a database query result, the method further includes: before adding the content identification of the content item in the database query result to the content identification set of the preset group in the cache, judging whether the residual survival time of the content identification set of the preset group is smaller than a preset time threshold value; if the content identifier is smaller than the predetermined group content identifier, the content identifier of the content item in the database query result is not added to the content identifier set of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, further includes: receiving a content distribution request from a client, wherein the content distribution request is used for distributing a preset content item in a preset group; and in response to the content publishing request, storing the predetermined content item to the cache, adding a content identification of the predetermined content item to a set of content identifications of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, before storing the predetermined content item in the cache in response to the content release request, and adding the content identifier of the predetermined content item to the content identifier set of the predetermined group in the cache, the method further includes: judging whether the predetermined content item meets the release condition; if the release condition is not satisfied, the predetermined content item is not stored to the cache, and the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, further includes: receiving a content editing request from a client, wherein the content editing request is used for editing a preset content item published in a preset group; deleting a predetermined content item stored in the cache in response to the content editing request; and judging whether to add the content identification of the preset content item to the content identification set of the preset group in the cache according to the content identification set of the preset group in the cache.
Optionally, in the method according to an embodiment of the present invention, determining whether to add the content identifier of the predetermined content item to the content identifier set of the predetermined group in the cache according to the content identifier set of the predetermined group in the cache includes: comparing the release time of the predetermined content item with the earliest release time of the content identification set of the predetermined group in the cache; if the release time of the predetermined content item is earlier than the earliest release time of the set of content identifications of the predetermined group in the cache, the content identification of the predetermined content item is not added to the set of content identifications of the predetermined group in the cache, otherwise the content identification of the predetermined content item is added to the set of content identifications of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, before determining whether to add the content identifier of the predetermined content item to the content identifier set of the predetermined group in the cache according to the content identifier set of the predetermined group in the cache, the method further includes: judging whether the residual survival time of the content identification set of the preset group in the cache is smaller than a preset time threshold value or not; if so, the content identification of the predetermined content item is not added to the set of content identifications of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, before determining whether the remaining lifetime of the content identification set of the predetermined group in the cache is less than the predetermined time threshold, the method further includes: judging whether the predetermined content item meets the release condition; if the distribution condition is not satisfied, the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache.
Optionally, in the method according to an embodiment of the present invention, further includes: receiving a content deletion request from a client, wherein the content deletion request is used for deleting the preset content items distributed in the preset group or canceling the distribution of the preset content items originally distributed in the preset group; in response to the content deletion request, the predetermined content item is deleted from the cache, and the content identification of the predetermined content item is deleted from the set of content identifications of the predetermined group in the cache.
According to another aspect of an embodiment of the present invention, there is provided a cache updating apparatus, the cache being adapted to store content items published to a group and a set of content identifications of the group, the set of content identifications including content identifications of content items published to corresponding groups, the content identifications in the set of content identifications being arranged in a time order of publication of the corresponding content items, the apparatus comprising: a communication module adapted to receive a content query request from a client for querying a predetermined number of content items published to a predetermined group; the content query module is suitable for responding to the content query request and querying in the cache and/or the database to obtain a target query result; and the cache updating module is suitable for storing the content items in the database query result into the cache if the target query result comprises the cache query result and the database query result, and adding the content identifications of the content items in the database query result into a content identification set of a preset group in the cache.
According to another aspect of an embodiment of the present invention, there is provided a social networking system including: the client is suitable for sending a content query request to the server, receiving a target query result returned by the server and displaying content items in the target query result; the server comprises a cache updating device which is suitable for responding to the content query request and returning a target query result to the client; a cache adapted to store content items published in groups and a set of content identifications for the groups; and a database adapted to store content items published and not published in the group.
According to another aspect of an embodiment of the present invention, there is provided a computing device including: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for performing any of the cache update methods according to embodiments of the present invention.
According to yet another aspect of an embodiment of the present invention, there is provided a readable storage medium storing a program comprising instructions that, when executed by a computing device, cause the computing device to perform any one of the cache update methods according to the embodiments of the present invention.
According to the cache updating scheme provided by the embodiment of the invention, the cache of the newly issued content item in the group can be realized by responding to the content query/issue/edit/delete request to correspondingly update the cache, so that the hit rate of the cache is effectively improved while the consistency of data and the correctness of service are ensured, the load of a database is reduced (the access frequency of the database is reduced), and the query speed is improved.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which set forth the various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to fall within the scope of the claimed subject matter. The above, as well as additional objects, features, and advantages of the present disclosure will become more apparent from the following detailed description when read in conjunction with the accompanying drawings. Like reference numerals generally refer to like parts or elements throughout the present disclosure.
FIG. 1 shows a schematic diagram of a social networking system 100, according to one embodiment of the present invention;
FIG. 2 shows a schematic diagram of a computing device 200 according to one embodiment of the invention;
FIG. 3 illustrates a schematic diagram of a cache update method 300 according to one embodiment of the invention;
FIG. 4 illustrates a schematic diagram of a cache update method 400 according to one embodiment of the invention; and
fig. 5 shows a schematic diagram of a cache update apparatus 500 according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
FIG. 1 shows a schematic diagram of a social networking system 100, according to one embodiment of the present invention. As shown in fig. 1, social-networking system 100 includes a client 110, a server 120, a cache 130, and a database 140. In other implementations, social-networking system 100 may also include different and/or additional modules.
A user may obtain services provided by social-networking system 100 by interacting with social-networking system 100. For example, a user may join a group or create a group on social-networking system 100. When a content item is published in a group, the content item will be shared to members of the group. When a user enters or refreshes a page of a group at client 110, client 110 will request a query from server 120 for a content item newly published in the group so that the content item may be displayed on the group page presented after the entry or refresh.
Specifically, the user may interact with the server 120 through the client 110, for example, transmitting various requests such as a content distribution request, a content editing request, a content deletion request, and a content query request. The server 120 comprises a cache updating apparatus 500 according to an embodiment of the invention and may respond to received requests, e.g. update/query the cache 130 and/or the database 140.
The database 140 may store content items, including content items published in groups and content items not published in groups. For example, database 140 may store published and unpublished tables of content for a group. Each distribution table of content is indexed by the group identification of a group and includes content items distributed in that group. Each published content table is indexed by a group identification of a group and includes content items not published in the group. The published and unpublished content tables in the database 140 may be updated in accordance with user operations on the content items. Each content item may be text, images, video, or any combination thereof, and may also include a timestamp to indicate the time of release of the content item.
In some embodiments, database 140 may be implemented as any suitable data storage system, such as a MySQL database.
The cache 130 may store at least some of the content items published in the group, such as newly published content items and/or frequently queried content items, and may also store content identifications of at least some of the content items published in the group (e.g., content identifications of content items newly published in the group). For example, the cache 130 may store content items with content identifications as index keys (keys) and may also store a set of content identifications for groups. The content items and the set of content identifications in the cache 130 may be updated in accordance with user operations on the content items. Each set of content identifications is indexed by a group identification of a group and includes content identifications of at least some of the content items published in the group, the content identifications having publication times of corresponding content items and being arranged in this publication time order (e.g., may be arranged in an ascending order of publication times).
It should be noted that the content items stored by the cache 130 and the index keys of the content identification set each have a lifetime (e.g. may be configured at creation time). When the remaining lifetime is 0, the index key of the corresponding content item or content identification set is deleted, and the corresponding content item or content identification set is also invalidated or deleted. In some embodiments, the length of expiration time for each content item or set of content identifications may be randomly configured, for example, in the range of 5 to 15 minutes.
In some embodiments, the buffer 130 has the characteristic of high read-write speed and high performance, and can be implemented as any suitable data buffer system. Preferably, the cache 130 may be a distributed system based on Redis, the content identification set of the group may be stored with a data structure zset (score as release time of the corresponding content item), and the content item may be stored with a data structure string.
The specific structure of the components in the social networking system 100 and the methods performed in the components will be described below in conjunction with the accompanying drawings. According to an embodiment of the invention, the components of the social networking system 100 may be implemented by the computing device 200 as described below.
FIG. 2 shows a schematic diagram of a computing device 200 according to one embodiment of the invention. As shown in FIG. 2, in a basic configuration 202, computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communication between the processor 204 and the system memory 206.
Depending on the desired configuration, the processor 204 may be any type of processing including, but not limited to: a microprocessor (μp), a microcontroller (μc), a digital information processor (DSP), or any combination thereof. Processor 204 may include one or more levels of cache, such as a first level cache 210 and a second level cache 212, a processor core 214, and registers 216. The example processor core 214 may include an Arithmetic Logic Unit (ALU), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof. The example memory controller 218 may be used with the processor 204, or in some implementations, the memory controller 218 may be an internal part of the processor 204.
Depending on the desired configuration, system memory 206 may be any type of memory including, but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. The system memory 206 may include an operating system 220, one or more applications 222, and program data 224. In some implementations, the application 222 may be arranged to execute instructions on an operating system by the one or more processors 204 using the program data 224.
Computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to basic configuration 202 via bus/interface controller 230. The example output device 242 includes a graphics processing unit 248 and an audio processing unit 250. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 252. The example peripheral interface 244 may include a serial interface controller 254 and a parallel interface controller 256, which may be configured to facilitate communication via one or more I/O ports 258 and external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.). The example communication device 246 may include a network controller 260 that may be arranged to facilitate communication with one or more other computing devices 262 over a network communication link via one or more communication ports 264.
The network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media in a modulated data signal, such as a carrier wave or other transport mechanism. A "modulated data signal" may be a signal that has one or more of its data set or changed in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or special purpose network, and wireless media such as acoustic, radio Frequency (RF), microwave, infrared (IR) or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
Computing device 200 may be implemented as a server, such as a database server, an application server, a WEB server, etc., or as a personal computer including desktop and notebook computer configurations. Of course, computing device 200 may also be implemented as part of a small-sized portable (or mobile) electronic device.
In an embodiment in accordance with the present invention, computing device 200 may be implemented as client 110 and server 120 and configured to perform cache update methods 300 and/or 400 in accordance with embodiments of the present invention (described in detail below). The application 222 of the computing device 200 includes a plurality of instructions for executing the cache update methods 300 and/or 400 according to the embodiments of the present invention, and the program data 224 may also store configuration information of the social networking system 100, etc.
FIG. 3 illustrates a schematic diagram of a cache update method 300 according to one embodiment of the invention. As shown in fig. 3, the cache update method 300 is performed in the server 120, and starts at step S310.
The client 110 may send a content distribution request to the server 120 for distributing predetermined content items in a predetermined group. Wherein the predetermined content item may be a new content item not stored in the database 140 or a content item stored in the database 140 but not published. For example, the content distribution request may include a predetermined content item or a content identification of the predetermined content item, and may further include a group identification of the predetermined group.
The server 120 may receive the content distribution request in step S310, store the predetermined content item to the cache 130 in response to the content distribution request in step S320, and add the content identification of the predetermined content item to the content identification set of the predetermined group in the cache 130. If the set of content identifications of the predetermined group has not been stored in the cache 130, a set of content identifications of the predetermined group including the content identifications of the predetermined content items may be created in the cache 130.
In some embodiments, the server 120 may also determine whether the predetermined content item satisfies the publication condition prior to step 320. The posting condition may be a condition such as passage of an audit of the content item, etc., and any suitable condition may be employed as the posting condition by embodiments of the present invention.
If the publishing condition is not met, the predetermined content item is not stored to the cache 130, nor is the content identification of the predetermined content item added to the set of content identifications of the predetermined group in the cache 130. If the publication condition is satisfied, step 320 is entered.
For example, a user publishes a topic 1 at group 1 via client 110. The server 120 stores the topic 1 in the publishing table of contents using "group 1" as an index key in the database 140, and after the topic 1 is checked, stores the topic 1 in the cache 130 using "topic 1" as an index key, and stores the content identifier "topic 1" of the topic 1 in the content identifier set using "group 1" as an index key in the cache 130.
According to one embodiment of the present invention, the client 110 may also send a content editing request to the server 120 for editing a predetermined content item published to a predetermined group. For example, the content of the predetermined content item may be edited.
The server 120 receives the content editing request in step S330, and then deletes the predetermined content item (if any) from the cache 130 in response to the content editing request in step S340, and determines whether to add the content identification of the predetermined content item to the content identification set of the predetermined group in the cache based on the content identification set of the predetermined group in the cache 130.
In particular, the release time of the predetermined content item may be compared to the earliest release time in the content identification set of the predetermined group in the cache 130. If the release time of the predetermined content item is earlier than the earliest release time of the set of content identifications of the predetermined group in the cache 130, the content identification of the predetermined content item is not added to the set of content identifications of the predetermined group in the cache 130. If the distribution time of the predetermined content item is not earlier than the earliest distribution time of the set of content identifications of the predetermined group in the cache 130, the content identification of the predetermined content item may be added to the set of content identifications of the predetermined group in the cache 130.
In some embodiments, before determining whether to add the content identification of the predetermined content item to the content identification set of the predetermined group in the cache 130 based on the content identification set of the predetermined group in the cache 130, it may be determined whether the remaining time-to-live (i.e., the remaining time-to-live, TTL) of the content identification set of the predetermined group in the cache 130 is less than a predetermined time threshold (e.g., a few seconds or milliseconds). If less than the predetermined time threshold, the content identification of the predetermined content item is not added to the set of content identifications of the predetermined group in the cache 130. If not less than the predetermined time threshold, it may be determined whether to add the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache 130 based on the set of content identifications of the predetermined group in the cache 130.
In addition, before determining whether the remaining survival time of the content identifier set of the predetermined group in the cache 130 is less than the predetermined time threshold, it may also be determined whether the predetermined content item satisfies a release condition, where the release condition includes at least that the content item is approved. If the distribution condition is not satisfied, it is not determined whether the remaining lifetime of the set of content identifications of the predetermined group in the cache 130 is less than the predetermined time threshold, at which time the content identifications of the predetermined content items are not added to the set of content identifications of the predetermined group in the cache 130, and the content identifications of the predetermined content items are also deleted (if any) from the set of content identifications of the predetermined group in the cache 130. If the publishing condition is met, a determination is made as to whether the remaining time to live for the set of content identification for the predetermined group in the cache 130 is less than a predetermined time threshold.
According to one embodiment of the present invention, the client 110 may also transmit a content deletion request for deleting or de-publishing a predetermined content item originally published in a predetermined group to the server 120. The server 120 may receive a content deletion request in step S350, delete a predetermined content item from the cache 130 in response to the content deletion request, and delete a content identification of the predetermined content item from a content identification set of a predetermined group in the cache 130 in step S360.
It should be noted that the server 120 updates the database 140 in addition to the cache 130 in response to the various requests described above. For example, in response to a content distribution request, a predetermined content item is stored to a distribution content table of a predetermined group in the database 140, or a predetermined content item is moved from an unpublished content table of a predetermined group in the database 140 to a distribution content table, or the like; in response to the content editing request, updating the predetermined content items stored in the database 140 (updating the content of the predetermined content items, and/or moving the predetermined content items from the published content table to the unpublished content table of the predetermined group, etc.); in response to the content deletion request, the predetermined content items stored in the database 140 are deleted, or the predetermined content items are moved from the published content table of the predetermined group to the unpublished content table, or the like.
FIG. 4 illustrates a flow diagram of a cache update method 400 according to one embodiment of the invention. The cache update method 400 is adapted to be executed in the server 120 and starts with step S410.
It will be appreciated that a user may browse pages of a group via client 110. When a user refreshes a page of a group, a content query request is sent to the server 120 to display the newly published content items of the group on the refreshed group page. When the user selects to turn pages on the group page, a content query request is also sent to the server 120 to obtain content items to continue to be displayed.
In step S410, the server 120 receives a content query request from the client 110 for querying a predetermined number of content items published in a predetermined group. In some embodiments, the content query request may include a group identification of a predetermined group and a predetermined number.
Then, in step S420, in response to the content query request, a query may be performed in the cache 130 and/or the database 140, to obtain a target query result. Here, for convenience of description later, the result obtained from the query of the cache 130 is referred to as a cache query result, and the result obtained from the query of the database 140 is referred to as a database query result.
Server 120 may return the target query result to client 110, with content items in the target query result displayed by client 110. In some embodiments, the target query result may include a publication time of the content item in addition to the content item, such that the client 110 displays the content items in the order of the publication time.
It will be appreciated that the target query result obtained in step S420 may be a cached query result (when the cache is fully hit), a database query result (when the cache is not hit), or a combination of both (when the cache is partially hit). In the case that the target query result includes both the cache query result and the database query result, the cache 130 may be updated based on the database query result in step S430, that is, the content items in the database query result are stored in the cache 130, and the content identifications of the content items in the database query result are added to the content identification set of the predetermined group in the cache 130.
The process of querying the cache 130 and/or the database 140 for the target query result in step S420 will be described below.
According to step S421, the server 120 may query the cache 130 for a predetermined number of content items published in a predetermined group with a publication time within a first time interval. The cache query result obtained at this time may include N content items and their distribution times, and the N content items may be arranged in order of distribution times.
The first time interval is a time interval designated by the content query request or a default time interval. According to one embodiment of the present invention, when the content query request does not specify a time interval, the first time interval is a default time interval. The default time interval is bounded right by the current time and left by the past time. Here, the current time refers to a time when the server 120 processes or receives the content query request, and the past time refers to a time earlier than the current time and sufficiently far from the current time, and may be 1970-01-00:00:00, for example.
In some embodiments, the server 120 may first query the cache 130 for a predetermined number of content identifications corresponding to the predetermined group, whose distribution time of the corresponding content item is located in the first time interval.
For example, server 120 may perform the following queries for content identification in cache 130:
ZREVRANGEBYSCORE GroupId begin _time end_ time WITHSCORES LIMIT req.count. Where GroupId represents a group identification of a predetermined group, begin_time represents a left boundary of a first time interval, end_time represents a right boundary of the first time interval, and count represents a predetermined number.
After the server 120 queries N content identifiers, the content items corresponding to the N content identifiers may be queried in the cache 130 according to the N content identifiers, so as to obtain N content items, that is, the query result is cached.
For example, server 120 may perform the following queries for content items in cache 130:
MGET TopicId 1TopicId 2 … … TopicId N. Wherein, topicId: 1-TopicId: N are N content identifications obtained in the query for the content identifications.
If there is a content identifier that is not queried from the cache 130 for a corresponding content item, the server 120 may query from the database 140 for a content item corresponding to the content identifier, and then combine with the content item queried from the cache 130 to obtain the cache query result. The server 120 may also store the content items, here queried from the database 140, to the cache 130.
According to some embodiments of the present invention, before step S421, the server 120 may determine whether the cache 130 stores the content identification set of the predetermined group, for example, whether an index key of the predetermined group (i.e., a group identification of the predetermined group) exists in the cache 130. If there is an index key of a predetermined group in the cache 130, i.e., the cache 130 stores the content identification set of the predetermined group, step S421 may be entered.
If there is no index key of the predetermined group in the cache 130, that is, the cache 130 does not store the content identifier set of the predetermined group, the server 120 may not query the cache 130, but directly query the database 140 for a predetermined number of content items with a release time within the first time interval, which are released in the predetermined group, and return the obtained database query result to the client 110 as a target query result.
After obtaining the database query result as the target query result, the server 120 stores the content items in the database query result in the cache 130, and determines whether to create a content identifier set corresponding to the predetermined group and including the content identifiers of the content items in the database query result in the cache 130 according to the first time interval.
For example, the right boundary of the first time interval may be compared to the current time instant (i.e., the time instant at which the server 120 processed or received the content query request). If the right boundary of the first time interval is not earlier than the current time instant, a set of content identifications corresponding to the predetermined group including the content identifications of the content items in the database query result is created in the cache 130. If the right boundary of the first time interval is earlier than the current time instant, a set of content identifications corresponding to the predetermined group including the content identifications of the content items in the database query result is not created in the cache 130.
According to an embodiment of the present invention, if the content items with the distribution time within the first time interval, which are distributed in the predetermined group, are not searched from the cache 130 (i.e., N is equal to 0 and the cache search result is null) in step S421, a predetermined number of content items with the distribution time within the first time interval, which are distributed in the predetermined group, may be searched in the database 140, and the obtained database search result may be returned to the client 110 as the target search result. In this case, the set of content identifications of the predetermined group in the cache 130 is not updated (i.e., the content identifications of the content items in the database query result are not added to the set of content identifications of the predetermined group in the cache 130), but the content items in the database query result may be stored to the cache 130.
If in step S421 a content item published in a predetermined group with a publication time in the first time interval is queried from the cache 130 (i.e. N is not equal to 0 and the cache query result is not null), then in step S422 the number N of content items in the cache query result of step S421 may be compared with the predetermined number.
When the number N of content items in the cached results is equal to the predetermined number, the server 120 does not update the set of content identifications for the predetermined group in the cache 130 (i.e., does not add the content identifications for the content items in the cached results to the set of content identifications for the predetermined group in the cache 130). But as previously described, when the cached results include a content item queried from database 140, the content item may be stored to cache 130.
When the number N of content items in the cached results is not equal to the predetermined number (i.e., N is less than the predetermined number), the server 120 may query the database 140 for the remaining number of content items published in the predetermined group whose publication time is within the second time interval according to step 423. The database query result obtained at this time may include M content items and their distribution times, which may be arranged in order of distribution times.
Wherein the remaining number is obtained by subtracting the number N of content items in the cached query result from the predetermined number. The second time interval is obtained based on the first time interval and the buffered polling result. For example, the second time interval may have the left boundary of the first time interval as its own left boundary and the earliest release time in the cached query result as its own right boundary.
For example, the following queries may be performed in database 140:
SELECT*FROM topic WHERE group_id=1ADN create_time<cache_result.minTimestamp AND create_time>=begin_time ORDER BY create_time DESC LIMIT req.count-cache_result.count”。
where topic represents the release content table in the database 140, group_id represents the group identifier of the predetermined group (group identifier is 1 in this example), create_time represents the release time of the content item, cache_result represents the cache query result, cache_result.mintimestamp represents the earliest release time in the cache query result, begin_time is the left boundary of the first time interval, req.count represents the predetermined number, and cache_result.count represents the number N of content items in the cache query result.
According to one embodiment of the present invention, if no content item with a distribution time within the second time interval, which is distributed in the predetermined group, is queried from the database 140 in step S423 (i.e. M is equal to 0, and the database query result is null), it may be considered that there is no content item with a distribution time within the second time interval, which is distributed in the predetermined group, and the server 120 returns the obtained cache query result as the target query result to the client 110, without updating the content identification set of the predetermined group in the cache 130.
If the content item with the distribution time within the second time interval, which is distributed in the predetermined group and is located in the second time interval, is queried from the database 140 in step S423 (i.e., M is not equal to 0, and the database query result is not null), the server 120 may combine the cached query result and the database query result to obtain the target query result in step S424.
At this time, the server 120 may add the content identifier of the content item in the database query result to the content identifier set of the predetermined group in the cache 130, and store the content item itself in the database query result to the cache 130 in step S430.
In some embodiments, if the target query result includes a cached query result and a database query result, the server 120 may further determine whether a remaining lifetime of the set of content identifications of the predetermined group is less than a predetermined time threshold before adding the content identifications of the content items in the database query result to the set of content identifications of the predetermined group in the cache. If the content identification of the content item in the database query result is smaller than the predetermined group content identification set in the cache, the content identification of the content item in the database query result is not added to the predetermined group content identification set in the cache, and if the content identification of the content item in the database query result is not smaller than the predetermined group content identification set in the cache.
Fig. 5 shows a schematic diagram of a cache update apparatus 500 according to an embodiment of the invention. As shown in fig. 5, the cache update apparatus 500 includes a communication module 510, a content query module 520, and a cache update module 530.
The communication module 510 is adapted to receive a content query request from a client for querying a predetermined number of content items published to a predetermined group. The content query module 520 is adapted to query in the cache 130 and/or the database 140 in response to the content query request to obtain a target query result. The cache update module 530 is adapted to store content items in the database query results to the cache 130 if the target query results comprise the cache query results and the database query results, and to add content identifications of the content items in the database query results to a set of content identifications of a predetermined group in the cache 130.
The corresponding processes in the modules of the cache updating apparatus 500 have been explained in detail in the detailed descriptions of the social networking system 100 and the cache updating methods 300 and 400 described above in conjunction with fig. 1 to 4, and the repeated descriptions thereof will be omitted.
In summary, according to the cache update scheme of the embodiment of the present invention, by correspondingly updating the cache in response to the content query/release/edit/delete request, the cache of the content item recently released in the group can be implemented, so that the cache hit rate is effectively improved while the consistency of the data and the correctness of the service are ensured, thereby reducing the database load (reducing the access frequency to the database), and increasing the query speed.
It should be understood that the various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions of the methods and apparatus of the present invention, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the various methods of the present invention in accordance with instructions in the program code stored in the memory.
By way of example, and not limitation, computer readable media comprise computer storage media and communication media. Computer-readable media include computer storage media and communication media. Computer storage media stores information such as computer readable instructions, data structures, program modules, or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
It should be appreciated that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
The embodiment of the invention also comprises the following steps: the method of A7, A2, further comprising: and if the content items which are issued in the preset group and have the issue time within the first time interval cannot be queried in the cache, querying a preset number of content items which are issued in the preset group and have the issue time within the first time interval in the database, and obtaining a database query result as a target query result. A8. the method of A7, wherein if no content items published to the predetermined group with publication times within a first time interval are queried in the cache, the method further comprises: after obtaining the database query result as the target query result, the content identification set of the preset group in the cache is not updated, and/or the content items in the database query result are stored in the cache. A9. the method of A2, wherein querying the cache for a predetermined number of content items published in a predetermined group with a publication time in a first time interval, comprises: querying a predetermined number of content identifiers which are published in the predetermined group and have publication times of corresponding content items located in the first time interval in the cache; and inquiring the corresponding content item in the cache based on the content identification obtained by the inquiry. A10, the method of A2, after querying a predetermined number of content items which are published in the predetermined group and have publication time within a first time interval in the cache and obtaining a cache query result, the method further comprises: and if the number of the content items in the cache query result is equal to the preset number, or the number of the content items in the cache query result is smaller than the preset number, but no content item which is issued to the preset group and has the issue time in a second time interval is queried from the database, taking the cache query result as a target query result, and not updating the content identification set of the preset group in the cache. A11, the method of A1, wherein if the target query result comprises a cached query result and a database query result, the method further comprises: before adding the content identification of the content item in the database query result to the content identification set of the preset group in the cache, judging whether the residual survival time of the content identification set of the preset group is smaller than a preset time threshold value; and if the content identification of the content item in the database query result is smaller than the predetermined group content identification set in the cache, not adding the content identification of the content item in the database query result to the predetermined group content identification set in the cache. A12, the method of A1, further comprising: receiving a content publishing request from a client, the content publishing request being for publishing a predetermined content item in a predetermined group; and in response to the content publishing request, storing the predetermined content item to the cache, adding a content identification of the predetermined content item to a set of content identifications of the predetermined group in the cache. A13. the method of a12, wherein, in response to the content publication request, before storing the predetermined content item in the cache and adding the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache, the method further comprises: judging whether the predetermined content item meets a release condition; if the release condition is not satisfied, the predetermined content item is not stored in the cache, and the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache. A14, the method of A1, further comprising: receiving a content editing request from a client, wherein the content editing request is used for editing a preset content item published in a preset group; deleting the predetermined content item stored in the cache in response to the content editing request; and judging whether to add the content identification of the preset content item to the content identification set of the preset group in the cache according to the content identification set of the preset group in the cache. A15. the method of a14, wherein determining whether to add the content identifier of the predetermined content item to the content identifier set of the predetermined group in the cache according to the content identifier set of the predetermined group in the cache includes: comparing the release time of the predetermined content item with the earliest release time of the content identification set of the predetermined group in the cache; if the release time of the preset content item is earlier than the earliest release time of the content identification set of the preset group in the cache, the content identification of the preset content item is not added to the content identification set of the preset group in the cache, otherwise, the content identification of the preset content item is added to the content identification set of the preset group in the cache. A16. the method of a14, wherein before determining whether to add the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache according to the set of content identifications of the predetermined group in the cache, the method further comprises: judging whether the residual survival time of the content identification set of the preset group in the cache is smaller than a preset time threshold value or not; if so, not adding the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache. The method of a17, a16, wherein prior to determining whether a remaining lifetime of the set of content identifications of the predetermined group in the cache is less than a predetermined time threshold, the method further comprises: judging whether the predetermined content item meets a release condition; if the release condition is not satisfied, the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache. A18, the method of A1, further comprising: receiving a content deletion request from a client, wherein the content deletion request is used for deleting the preset content items distributed in the preset group or canceling the distribution of the preset content items originally distributed in the preset group; in response to the content deletion request, deleting the predetermined content item from the cache, deleting a content identification of the predetermined content item from a set of content identifications of the predetermined group in the cache.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into a plurality of sub-modules.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component and, furthermore, they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, may be used in combination, except insofar as at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
Furthermore, some of the embodiments are described herein as methods or combinations of method elements that may be implemented by a processor of a computer system or by other means of performing the functions. Thus, a processor with the necessary instructions for implementing the described method or method element forms a means for implementing the method or method element. Furthermore, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is for carrying out the functions performed by the elements for carrying out the objects of the invention.
As used herein, unless otherwise specified the use of the ordinal terms "first," "second," "third," etc., to describe a general object merely denote different instances of like objects, and are not intended to imply that the objects so described must have a given order, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of the above description, will appreciate that other embodiments are contemplated within the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is intended to be illustrative, but not limiting, of the scope of the invention, which is defined by the appended claims.

Claims (21)

1. A cache update method, the cache being adapted to store content items published to a group and a set of content identifications of the group, the set of content identifications including content identifications of content items published to corresponding groups, the content identifications in the set of content identifications being arranged in a time order of publication of the corresponding content items, the method comprising:
receiving a content query request from a client, the content query request being for querying a predetermined number of content items published to a predetermined group;
Responding to the content query request, and querying a preset number of content items which are issued in the preset group and have issue times in a first time interval in the cache to obtain a cache query result, wherein the first time interval is a time interval or a default time interval designated by the content query request;
comparing the number of content items in the cached query result with the predetermined number;
if the number of the content items in the cache query result is smaller than the preset number, querying the database for the residual number of the content items which are issued in the preset group and the issue time of which is positioned in a second time interval, so as to obtain a database query result, wherein the second time interval is obtained based on the first time interval and the cache query result, and the residual number is the difference between the preset number and the number of the content items in the cache query result;
combining the cache query result and the database query result to obtain a target query result; and
if the target query result comprises a cache query result and a database query result, storing content items in the database query result into the cache, and adding content identifications of the content items in the database query result to the content identification set of the preset group in the cache.
2. The method of claim 1, wherein the second time interval is derived based on the first time interval and the cached query result, comprising:
and taking the left boundary of the first time interval as the left boundary of the second time interval, and taking the earliest release time in the cache query result as the right boundary of the second time interval.
3. The method of claim 1 or 2, wherein in response to the content query request, querying in a cache and/or a database to obtain a target query result, further comprising:
inquiring a preset number of content items which are issued to the preset group and the issue time of which is positioned in a first time interval in the cache, and judging whether the cache stores a content identification set of the preset group or not;
and if the cache does not store the content identification set of the preset group, inquiring a preset number of content items which are issued in the preset group and have the issue time in a first time interval in the database, and obtaining a database inquiry result as a target inquiry result.
4. The method of claim 3, wherein if the cache does not store the set of content identifications of the predetermined group, the method further comprises:
After obtaining a database query result as a target query result, storing content items in the database query result into the cache;
and judging whether to create a content identification set of the preset group comprising the content identifications of the content items in the database query result in the cache according to the first time interval.
5. The method of claim 4, wherein determining whether to create the set of content identifications of the predetermined group including content identifications of content items in the target query result in the cache based on the first time interval comprises:
comparing the right boundary of the first time interval with the current moment;
if the right boundary of the first time interval is not earlier than the current time, creating a content identification set of the preset group comprising the content identifications of the content items in the target query result in the cache, otherwise, not creating the content identification set of the preset group comprising the content identifications of the content items in the target query result in the cache.
6. The method of claim 1, further comprising:
and if the content items which are issued in the preset group and have the issue time within the first time interval cannot be queried in the cache, querying a preset number of content items which are issued in the preset group and have the issue time within the first time interval in the database, and obtaining a database query result as a target query result.
7. The method of claim 6, wherein if no content items published to the predetermined group that are within a first time interval of publication time are queried in the cache, the method further comprising:
after obtaining the database query result as the target query result, the content identification set of the preset group in the cache is not updated, and/or the content items in the database query result are stored in the cache.
8. The method of claim 1, wherein querying the cache for a predetermined number of content items published in a predetermined group having a publication time within a first time interval comprises:
querying a predetermined number of content identifiers which are published in the predetermined group and have publication times of corresponding content items located in the first time interval in the cache;
and inquiring the corresponding content item in the cache based on the content identification obtained by the inquiry.
9. The method of claim 1, wherein after querying the cache for a predetermined number of content items published to the predetermined group and having a publication time within a first time interval, obtaining a cache query result, the method further comprises:
and if the number of the content items in the cache query result is equal to the preset number, or the number of the content items in the cache query result is smaller than the preset number, but no content item which is issued to the preset group and has the issue time in a second time interval is queried from the database, taking the cache query result as a target query result, and not updating the content identification set of the preset group in the cache.
10. The method of claim 1, wherein, if the target query result includes a cached query result and a database query result, the method further comprises:
before adding the content identification of the content item in the database query result to the content identification set of the preset group in the cache, judging whether the residual survival time of the content identification set of the preset group is smaller than a preset time threshold value;
and if the content identification of the content item in the database query result is smaller than the predetermined group content identification set in the cache, not adding the content identification of the content item in the database query result to the predetermined group content identification set in the cache.
11. The method of claim 1, further comprising:
receiving a content publishing request from a client, the content publishing request being for publishing a predetermined content item in a predetermined group; and
in response to the content publication request, storing the predetermined content item to the cache, adding a content identification of the predetermined content item to a set of content identifications of the predetermined group in the cache.
12. The method of claim 11, wherein, in response to the content publication request, storing the predetermined content item to the cache, before adding the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache, the method further comprises:
Judging whether the predetermined content item meets a release condition;
if the release condition is not satisfied, the predetermined content item is not stored in the cache, and the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache.
13. The method of claim 1, further comprising:
receiving a content editing request from a client, wherein the content editing request is used for editing a preset content item published in a preset group;
deleting the predetermined content item stored in the cache in response to the content editing request;
and judging whether to add the content identification of the preset content item to the content identification set of the preset group in the cache according to the content identification set of the preset group in the cache.
14. The method of claim 13, wherein determining whether to add the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache based on the set of content identifications of the predetermined group in the cache comprises:
comparing the release time of the predetermined content item with the earliest release time of the content identification set of the predetermined group in the cache;
If the release time of the preset content item is earlier than the earliest release time of the content identification set of the preset group in the cache, the content identification of the preset content item is not added to the content identification set of the preset group in the cache, otherwise, the content identification of the preset content item is added to the content identification set of the preset group in the cache.
15. The method of claim 13, wherein prior to determining whether to add the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache based on the set of content identifications of the predetermined group in the cache, the method further comprises:
judging whether the residual survival time of the content identification set of the preset group in the cache is smaller than a preset time threshold value or not;
if so, not adding the content identification of the predetermined content item to the set of content identifications of the predetermined group in the cache.
16. The method of claim 15, wherein prior to determining whether a remaining time-to-live of the set of content identifications of the predetermined group in the cache is less than a predetermined time threshold, the method further comprises:
Judging whether the predetermined content item meets a release condition;
if the release condition is not satisfied, the content identification of the predetermined content item is not added to the content identification set of the predetermined group in the cache.
17. The method of claim 1, further comprising:
receiving a content deletion request from a client, wherein the content deletion request is used for deleting the preset content items distributed in the preset group or canceling the distribution of the preset content items originally distributed in the preset group;
in response to the content deletion request, deleting the predetermined content item from the cache, deleting a content identification of the predetermined content item from a set of content identifications of the predetermined group in the cache.
18. A cache updating apparatus, the cache being adapted to store content items published to a group and a set of content identifications of the group, the set of content identifications including content identifications of content items published to corresponding groups, the content identifications in the set of content identifications being arranged in a time order of publication of the corresponding content items, the apparatus comprising:
a communication module adapted to receive a content query request from a client for querying a predetermined number of content items published to a predetermined group;
The content query module is suitable for responding to the content query request and querying in a cache and/or a database to obtain a target query result, and comprises the following steps: querying a preset number of content items which are issued in the preset group and the issue time of which is positioned in a first time interval in the cache to obtain a cache query result, wherein the first time interval is a time interval or a default time interval designated by the content query request; comparing the number of content items in the cached query result with the predetermined number; if the number of the content items in the cache query result is smaller than the preset number, querying the database for the residual number of the content items which are issued in the preset group and the issue time of which is positioned in a second time interval, so as to obtain a database query result, wherein the second time interval is obtained based on the first time interval and the cache query result, and the residual number is the difference between the preset number and the number of the content items in the cache query result; combining the cache query result and the database query result to obtain a target query result; and
and the cache updating module is suitable for storing the content items in the database query result into the cache if the target query result comprises the cache query result and the database query result, and adding the content identifications of the content items in the database query result into the content identification set of the preset group in the cache.
19. A social networking system, comprising:
the client is suitable for sending a content query request to the server, receiving a target query result returned by the server and displaying content items in the target query result;
a server comprising the cache updating means of claim 18 adapted to return the target query result to a client in response to the content query request;
a cache adapted to store content items published in groups and a set of content identifications for the groups; and
a database adapted to store content items published and not published in the group.
20. A computing device, comprising:
one or more processors;
a memory; and
one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing any of the cache update methods of claims 1-17.
21. A readable storage medium storing a program comprising instructions that, when executed by a computing device, cause the computing device to perform any of the cache update methods of claims 1-17.
CN202110151529.3A 2021-02-03 2021-02-03 Cache updating method and device and social network system Active CN112883307B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110151529.3A CN112883307B (en) 2021-02-03 2021-02-03 Cache updating method and device and social network system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110151529.3A CN112883307B (en) 2021-02-03 2021-02-03 Cache updating method and device and social network system

Publications (2)

Publication Number Publication Date
CN112883307A CN112883307A (en) 2021-06-01
CN112883307B true CN112883307B (en) 2023-10-20

Family

ID=76057022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110151529.3A Active CN112883307B (en) 2021-02-03 2021-02-03 Cache updating method and device and social network system

Country Status (1)

Country Link
CN (1) CN112883307B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113395369B (en) * 2021-06-10 2022-12-13 北京天融信网络安全技术有限公司 Cache management method and device, electronic equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902696A (en) * 2011-07-29 2013-01-30 国际商业机器公司 Method and equipment for managing content of social network
CN105338016A (en) * 2014-06-27 2016-02-17 国际商业机器公司 Data caching method, device, resource request responding method and device
CN106372136A (en) * 2010-12-30 2017-02-01 脸谱公司 Distributed cache system and method and storage medium
CN107644071A (en) * 2017-09-18 2018-01-30 广州爱九游信息技术有限公司 Buffering updating method, device and data-storage system
CN107851277A (en) * 2015-08-10 2018-03-27 谷歌有限责任公司 The consistent and personalized social media content of privacy is shared to recommend
CN108647357A (en) * 2018-05-17 2018-10-12 阿里巴巴集团控股有限公司 The method and device of data query
CN110032567A (en) * 2019-04-24 2019-07-19 江苏满运软件科技有限公司 Report form inquiring method, device, server and storage medium
CN110765138A (en) * 2019-10-31 2020-02-07 北京达佳互联信息技术有限公司 Data query method, device, server and storage medium
CN111597214A (en) * 2019-02-21 2020-08-28 北京京东尚科信息技术有限公司 Method, apparatus, computer system and medium for data query
CN111737564A (en) * 2019-08-29 2020-10-02 北京京东尚科信息技术有限公司 Information query method, device, equipment and medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9514243B2 (en) * 2009-12-03 2016-12-06 Microsoft Technology Licensing, Llc Intelligent caching for requests with query strings
US20160371391A1 (en) * 2015-06-17 2016-12-22 Qualcomm Incorporated Caching search-related data in a semi-structured database

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106372136A (en) * 2010-12-30 2017-02-01 脸谱公司 Distributed cache system and method and storage medium
CN102902696A (en) * 2011-07-29 2013-01-30 国际商业机器公司 Method and equipment for managing content of social network
CN105338016A (en) * 2014-06-27 2016-02-17 国际商业机器公司 Data caching method, device, resource request responding method and device
CN107851277A (en) * 2015-08-10 2018-03-27 谷歌有限责任公司 The consistent and personalized social media content of privacy is shared to recommend
CN107644071A (en) * 2017-09-18 2018-01-30 广州爱九游信息技术有限公司 Buffering updating method, device and data-storage system
CN108647357A (en) * 2018-05-17 2018-10-12 阿里巴巴集团控股有限公司 The method and device of data query
CN111597214A (en) * 2019-02-21 2020-08-28 北京京东尚科信息技术有限公司 Method, apparatus, computer system and medium for data query
CN110032567A (en) * 2019-04-24 2019-07-19 江苏满运软件科技有限公司 Report form inquiring method, device, server and storage medium
CN111737564A (en) * 2019-08-29 2020-10-02 北京京东尚科信息技术有限公司 Information query method, device, equipment and medium
CN110765138A (en) * 2019-10-31 2020-02-07 北京达佳互联信息技术有限公司 Data query method, device, server and storage medium

Also Published As

Publication number Publication date
CN112883307A (en) 2021-06-01

Similar Documents

Publication Publication Date Title
US10754846B2 (en) Age-based policies for determining database cache hits
CN111651464B (en) Data processing method, system and computing device
CN107197359B (en) Video file caching method and device
CN110737682A (en) cache operation method, device, storage medium and electronic equipment
CN109558378A (en) File management method, device, equipment and storage medium
US8352442B2 (en) Determination of an updated data source from disparate data sources
US20220350741A1 (en) In-memory normalization of cached objects to reduce cache memory footprint
CN113377289A (en) Cache management method, system, computing device and readable storage medium
US8538980B1 (en) Accessing forms using a metadata registry
CN112883307B (en) Cache updating method and device and social network system
CN112559913B (en) Data processing method, device, computing equipment and readable storage medium
US10909146B2 (en) Providing automated hashtag suggestions to categorize communication
US11570229B2 (en) Method and system for enforcing governance across multiple content repositories using a content broker
US10664170B2 (en) Partial storage of large files in distinct storage systems
CN111444448B (en) Data processing method, server and system
CN111178965B (en) Resource release method and server
US20150081576A1 (en) Generating a supplemental description of an entity
CN114090692A (en) Full-media-asset data synchronization method, system, device and computer-readable storage medium
CN110889053B (en) Interface data caching method and device and computing equipment
CN113032820B (en) File storage method, access method, device, equipment and storage medium
EP3455805A1 (en) Enhancing contact card based on knowledge graph
CN112988874A (en) Data processing method, system, computing device and readable storage medium
US20160150038A1 (en) Efficiently Discovering and Surfacing Content Attributes
US20180074867A1 (en) Provide copy of notebook document
US20180341717A1 (en) Providing instant preview of cloud based file

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