A kind of update method and device of card data
Technical field
This specification is related to the update method and device of Internet technical field more particularly to a kind of card data.
Background technique
In mobile client, there are many interfaces or scene, part of interface or scene are by the form of multiple cards
Composition.For example, in the wealth Tab page of Alipay, different location can show different information, such as total assets, financing
These are shown that the position of different information is known as different cards by service and finance product etc..
In the prior art, client clocked flip RPC interface is usually relied on, and then obtains data, full dose brush from server
New all cards, and the problem of prior art client timing initiation RPC request, is, it may be necessary to quickly user is allowed to see certain
The newest variation of card data, and client can not obtain the data in time.
Summary of the invention
In view of the above technical problems, this specification embodiment provides the update method and device of a kind of card data, technology
Scheme is as follows:
According to this specification embodiment in a first aspect, provide a kind of update method of card data, this method comprises:
Client receives server according to the card data of the push logic push prestored, the push logic packet prestored
Include the push trigger condition of a variety of card datas;
Client traverses the card data, carries out the local of card more according to the rule field for including in card data
Newly;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Updating type field is included at least in agreement, the updating type field includes that card layout updates inside rule and/or card
Data update rule.
According to the second aspect of this specification embodiment, a kind of updating device of card data is provided, which includes:
Data reception module: for making client receive the card data that server is pushed according to the push logic prestored,
The push logic prestored includes the push trigger condition of a variety of card datas;
Card update module: for making client traverse the card data, according to the regular word for including in card data
The local update of Duan Jinhang card;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Updating type field is included at least in agreement, the updating type field includes that card layout updates inside rule and/or card
Data update rule.
According to the third aspect of this specification embodiment, a kind of computer equipment is provided, including memory, processor and deposit
Store up the computer program that can be run on a memory and on a processor, wherein the processor is realized when executing described program
A kind of update method of card data, this method include
Client receives server according to the card data of the push logic push prestored, the push logic packet prestored
Include the push trigger condition of a variety of card datas;
Client traverses the card data, carries out the local of card more according to the rule field for including in card data
Newly;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Updating type field is included at least in agreement, the updating type field includes that card layout updates inside rule and/or card
Data update rule.
Technical solution provided by this specification embodiment provides the update method and device of a kind of card data, removes
User end to server initiates RPC request to refresh outside full dose card data, is also prefixed actively in server-side to client
The triggering logic for pushing card data, using general sync function, the card that needs are updated according to preset agreement
Incremental data is pushed, so that user be made to see newest data as early as possible, promotes user experience.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
This specification embodiment can be limited.
In addition, any embodiment in this specification embodiment does not need to reach above-mentioned whole effects.
Detailed description of the invention
In order to illustrate more clearly of this specification embodiment or technical solution in the prior art, below will to embodiment or
Attached drawing needed to be used in the description of the prior art is briefly described, it should be apparent that, the accompanying drawings in the following description is only
The some embodiments recorded in this specification embodiment for those of ordinary skill in the art can also be attached according to these
Figure obtains other attached drawings.
Fig. 1 is a kind of flow chart of the update method of the card data shown in one exemplary embodiment of this specification;
Fig. 2 is another flow chart of the update method of the card data shown in one exemplary embodiment of this specification;
Fig. 3 is a kind of schematic diagram of the updating device of the card data shown in one exemplary embodiment of this specification;
Fig. 4 is a kind of structural schematic diagram of computer equipment shown in one exemplary embodiment of this specification.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with this specification.On the contrary, they are only and such as institute
The example of the consistent device and method of some aspects be described in detail in attached claims, this specification.
It is only to be not intended to be limiting this explanation merely for for the purpose of describing particular embodiments in the term that this specification uses
Book.The "an" of used singular, " described " and "the" are also intended to packet in this specification and in the appended claims
Most forms are included, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein is
Refer to and includes that one or more associated any or all of project listed may combine.
It will be appreciated that though various information may be described using term first, second, third, etc. in this specification, but
These information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not taking off
In the case where this specification range, the first information can also be referred to as the second information, and similarly, the second information can also be claimed
For the first information.Depending on context, word as used in this " if " can be construed to " ... when " or
" when ... " or " in response to determination ".
In mobile client, there are many interfaces or scene, part of interface or scene are by the form of multiple cards
Composition.For example, in the wealth Tab page of Alipay, different location can show different information, such as total assets, financing
These are shown that the position of different information is known as different cards by service and finance product etc..
In the prior art, client clocked flip RPC interface is usually relied on, and then obtains data, full dose brush from server
New all cards, and the problem of prior art client timing initiation RPC request, is, it may be necessary to quickly user is allowed to see certain
The newest variation of card data, and client can not obtain the data in time.
In view of the above problems, this specification embodiment provides a kind of update method of card data, and a kind of for holding
The updating device of the card data of row this method.The update method for the card data being related to below to the present embodiment carries out specifically
Bright, shown in Figure 1, this method may comprise steps of:
S101, client receive server according to the card data of the push logic push prestored, the push prestored
Logic includes the push trigger condition of a variety of card datas;
After client receives card data of the server according to the push logic push prestored, it is also necessary to obtain card data
In include user identifier, compared with local user identifier, if the two is different, stop the update stream of card data
Journey.
S102, client traverse the card data, and the sheet of card is carried out according to the rule field for including in card data
Ground updates;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Updating type field is included at least in agreement, the updating type field includes that card layout updates inside rule and/or card
Data update rule.
In a kind of embodiment of this specification, sync agreement may include following field:
1) subBiz, updating type field distinguish the modification of card layout or repairing for card internal data according to the field
Change;
Specifically, when updating type subBiz field is " CRUD_CARD ", indicate that this is revised as card layout and repairs
Change, i.e., the different cards of client are increased in card rank, deletes, modification operation.
Specifically, when updating type subBiz field is " when CRUD_JSON_RESULT ", to indicate that this is revised as card
Internal data modification modifies to card inner element by the jsonpatch instruction made an appointment.
2) timestamp, time record field, for recording current server time, for example, the field can
For " 1509502232000 ".
3) actionModel, card renewal model field are used for recording card renewal model;
Further, it may also include type field under actionModel field, actionModel.type field is for true
This fixed card is updated to server to client push data or client from server request data;
Specifically, when actionModel.type field is " command ", expression renewal model is command mode, i.e.,
Order client initiates RPC request of data to server-side, is obtained and is corresponded to from server according to the content for including in RPC request of data
Card data.
Specifically, when actionModel.type field is " data ", expression renewal model is data pattern, i.e., by taking
Business device directly issues card data to client.
Further, it may also include action field under actionModel field;
Action field should increase card for determination, and operation is deleted or modified;Specifically, when the field is
When add, to increase card newly;When the field is update, to update card;When the field is delete, to delete card.
Further, it may also include commandType field under actionModel field;
Under command command mode, when client initiates RPC request of data to server-side, use
It may include specifically following field that commandType field, which specifies the dependency rule of rpc request:
Rule, for updating floor information and card image.
Data, for updating the data of specified card.
Further, it may also include actionModel.index under actionModel field, increased card is wanted in expression
Position;
Further, it may also include actionModel.cardTypeIds under actionModel field, expression will operate
Card list, for deleting card;
4) cardModel, for recording the card data sync table to be modified, for increasing, updating card;
5) jsonPatch, jsonPatch field, for the directly modification card data of the JSON instruction by making an appointment.
The specific structure of sync agreement is illustrated, as follows:
{
"subBiz":"CRUD_CARD/CRUD_JSON_RESULT",
"timestamp":"1509502232000",
"cardModel":[{}],
"actionModel":
{"type":"command/data",
"action":"add/delete/update",
"commandType":"data/rule",
"index":0,
"cardTypeIds":["XXX_CARD"],},
“jsonPatch”:{}}
This specification embodiment also provides a kind of update method of more specifically card data, shown in Figure 2, the party
Method may comprise steps of:
S201 receives card data;
S202 traverses card data;
Do S203, traversal terminate? if traversal terminates, step S209 is executed, if traversal is not over, executes step
S204;
Do are S204, updating type that additions and deletions change card data? if updating type is that additions and deletions change card data, step is executed
S205, updating type are not that additions and deletions change card data, execute step S206;
With reference to sync protocol fields described above, when the subBiz field of data is that " when CRUD_CARD ", can determine that the number
Change card data according to for additions and deletions.
S205 is recorded additions and deletions and changes sync table;
Do are S206, updating type modification card internal data? if updating type is modification card internal data, step is executed
Rapid S207, updating type are not modification card internal data, execute step S208;
With reference to sync protocol fields described above, when the subBiz field of data is " when CRUD_JSON_RESULT ", it can
The data are determined to modify card internal data.
Internal data modification sync table is recorded in S207;
Third party's business datum sync table is recorded in S208;
S209, processing additions and deletions change sync table;
Specifically, the sync order sync table that card additions and deletions change need to be traversed, determines the update mould for including in sync table data
Formula field;
With reference to sync protocol fields described above, if the renewal model field actionModel.type is command,
Trigger the rpc request of client;
If the renewal model field actionModel.type is data, directly card is increased according to sync data
Add, delete and modifies.
S210, processing internal data modify sync table;
In particular it is required that the data portion of agreement card is json character string, while arranging a set of jsonpatch agreement.
When client receives the sync order of jsonpatch, jsonpatch instruction can be executed directly to modify card data.
In a kind of embodiment of this specification, jsonpatch agreement may include following field:
1.op: instruction type: expression increases card data, operation is deleted or modified, it may be assumed that add/remove/
replace;
2.path: path: the mode that element position to be operated is begun looking for from root path is indicated, i.e., by underscore point
It cuts, each layer of expression key or index query condition.
3.value: the specific element to be used when add/replace is indicated.
Specifically, operational order type is as follows:
1.add increases;
1.1jsonobject:
Citing: { op:add, path: "/a/b/c ", value:xxx }, when indicating to increase field under the/path a/b, key
For c, it is worth for value.If key has existed, with new value covering.
1.2jsonarray:
Citing: { op:add, path: "/a/b/3 ", value:xxx } is to increase an element at 3 in index index.Such as
Fruit can not find this index, not operate.
1.3jsonarray:
Citing: when query condition is key1=x&key2=y, { op:add, path: "/a/b/? key1=x&key2=
y",value:xxx}.The position index for meeting query condition at first increases an element.If according to query condition
It searches less than not adding then.
2.remove is deleted;
2.1jsonobject:
Citing: { op:remove, path: "/a/b/c " } deletes the element that key is c under the/path a/b.
2.2jsonArray:
Citing: { op:remove, path: "/a/b/3 " } deletes the element that index is 3 under the/path a/b.If looked for
Less than this index, do not operate.
2.3jsonArray deletes the element for meeting query condition
Citing: op:remove, path: "/a/b/? key1=x&key2=y " };Under/the path a/b, deleting key1 is
The element that x and key2 are y.If can not find the element for meeting query condition, do not operate.
3.replace updates;
3.1jsonobject
Citing: the value for the field that key is c is updated to by { op:replace, path: "/a/b/c ", value:xxx }
value。
3.2jsonarray
Citing: { op:replace, path: "/a/b/3 ", value:xxx } is more new element at 3 in index index.Such as
Fruit can not find this index, not operate.
3.3jsonarray is in the index location updating element for meeting query condition.If according to query conditional search
Less than not updating.
Citing: being key1=x&key2=y when issuing query condition, and jsonpatch is { op:replace, path: "/
A/b/? key1=x&key2=y ", value:xxx } instruction when, corresponding sync data are as follows:
Wherein, protocol format is issued as described above for JSONPatch instruction, and for every card, can be held
The multiple JSONPatch instructions of row.
S211 uses corresponding third party's resume module third party business datum sync table.
Wherein, additions and deletions change sync table and general module can be used to be handled for internal data modification sync table, third party's industry
Business data sync table is needed to be carried out using corresponding third party's module, under normal circumstances, can directly notified because being related to third party
Corresponding third party handles the data in the sync table.
Corresponding to above method embodiment, this specification embodiment also provides a kind of updating device of card data, referring to
Shown in Fig. 3, the apparatus may include: data reception module 310, card update module 320.
Data reception module 310: for making client receive server according to the number of cards of the push logic push prestored
According to the push logic prestored includes the push trigger condition of a variety of card datas;
Card update module 320: for making client traverse the card data, according to the rule for including in card data
The local update of field progress card;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Updating type field is included at least in agreement, the updating type field includes that card layout updates inside rule and/or card
Data update rule.
This specification embodiment also provides a kind of computer equipment, includes at least memory, processor and is stored in
On reservoir and the computer program that can run on a processor, wherein processor realizes aforementioned number of cards when executing described program
According to update method, the method includes at least:
Client receives server according to the card data of the push logic push prestored, the push logic packet prestored
Include the push trigger condition of a variety of card datas;
Client traverses the card data, carries out the local of card more according to the rule field for including in card data
Newly;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Card layout is included at least in agreement updates rule and/or card internal data update rule.
Fig. 4 shows one kind provided by this specification embodiment and more specifically calculates device hardware structural schematic diagram,
The equipment may include: processor 1010, memory 1020, input/output interface 1030, communication interface 1040 and bus
1050.Wherein processor 1010, memory 1020, input/output interface 1030 and communication interface 1040 are real by bus 1050
The now communication connection inside equipment each other.
Processor 1010 can use general CPU (Central Processing Unit, central processing unit), micro- place
Reason device, application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or one
Or the modes such as multiple integrated circuits are realized, for executing relative program, to realize technical side provided by this specification embodiment
Case.
Memory 1020 can use ROM (Read Only Memory, read-only memory), RAM (Random Access
Memory, random access memory), static storage device, the forms such as dynamic memory realize.Memory 1020 can store
Operating system and other applications are realizing technical solution provided by this specification embodiment by software or firmware
When, relevant program code is stored in memory 1020, and execution is called by processor 1010.
Input/output interface 1030 is for connecting input/output module, to realize information input and output.Input and output/
Module can be used as component Configuration (not shown) in a device, can also be external in equipment to provide corresponding function.Wherein
Input equipment may include keyboard, mouse, touch screen, microphone, various kinds of sensors etc., output equipment may include display,
Loudspeaker, vibrator, indicator light etc..
Communication interface 1040 is used for connection communication module (not shown), to realize the communication of this equipment and other equipment
Interaction.Wherein communication module can be realized by wired mode (such as USB, cable etc.) and be communicated, can also be wirelessly
(such as mobile network, WIFI, bluetooth etc.) realizes communication.
Bus 1050 include an access, equipment various components (such as processor 1010, memory 1020, input/it is defeated
Outgoing interface 1030 and communication interface 1040) between transmit information.
It should be noted that although above equipment illustrates only processor 1010, memory 1020, input/output interface
1030, communication interface 1040 and bus 1050, but in the specific implementation process, which can also include realizing normal fortune
Other assemblies necessary to row.In addition, it will be appreciated by those skilled in the art that, it can also be only comprising real in above equipment
Component necessary to existing this specification example scheme, without including all components shown in figure.
This specification embodiment also provides a kind of computer readable storage medium, is stored thereon with computer program, the journey
Realize that the update method of card data above-mentioned, the method include at least when sequence is executed by processor:
Client receives server according to the card data of the push logic push prestored, the push logic packet prestored
Include the push trigger condition of a variety of card datas;
Client traverses the card data, carries out the local of card more according to the rule field for including in card data
Newly;
Wherein, the SYNC agreement made an appointment, the SYNC are deferred to when pushing card data between client and server
Card layout is included at least in agreement updates rule and/or card internal data update rule.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality
Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit
The unit of explanation may or may not be physically separated, and component shown as a unit can be or can also be with
It is not physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to actual
The purpose for needing to select some or all of the modules therein to realize this specification scheme.Those of ordinary skill in the art are not
In the case where making the creative labor, it can understand and implement.
As seen through the above description of the embodiments, those skilled in the art can be understood that this specification
Embodiment can be realized by means of software and necessary general hardware platform.Based on this understanding, this specification is implemented
Substantially the part that contributes to existing technology can be embodied in the form of software products the technical solution of example in other words,
The computer software product can store in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are to make
It is each to obtain computer equipment (can be personal computer, server or the network equipment etc.) execution this specification embodiment
Method described in certain parts of a embodiment or embodiment.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment
The combination of any several equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device reality
For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method
Part explanation.The apparatus embodiments described above are merely exemplary, wherein described be used as separate part description
Module may or may not be physically separated, can be each module when implementing this specification example scheme
Function realize in the same or multiple software and or hardware.Can also select according to the actual needs part therein or
Person's whole module achieves the purpose of the solution of this embodiment.Those of ordinary skill in the art are not the case where making the creative labor
Under, it can it understands and implements.
The above is only the specific embodiment of this specification embodiment, it is noted that for the general of the art
For logical technical staff, under the premise of not departing from this specification embodiment principle, several improvements and modifications can also be made, this
A little improvements and modifications also should be regarded as the protection scope of this specification embodiment.