Surface by four

Idempotence control mechanisms

Database idempotent

Idempotent and transactions on the database are one.
1. query 
query query several times and once, in the case of the same data, the query result is the same. select natural power and other operations 
 2. Delete operation 
deletion idempotent, delete, delete one or many times the data are deleted. (Note may return the results are not the same, delete the data does not exist, returns 0, deleted data multiple return results more) 
3. unique index to prevent new dirty data 
such as: Alipay capital account, Alipay also has user accounts, each user can have only one fund account, how to prevent the user to create multiple funds account, then to the capital account of the table user ID plus a unique index, so a user to add a successful capital account records 

4. pessimistic lock 
when acquiring data acquired lock 
select * from table_xxx where id = '  xxx' for update;
Note: id field must be unique primary key or index, or a lock table, will be dead 
generally accompanied transaction when using pessimistic locking used together, the data lock time can be very long, according to the actual situation choice 
5. optimistic locking 
optimistic locking only in the moment of updating the data table locks, table locks other times not so pessimistic relative to the lock, higher efficiency.

ActiveMQ and RabbitMQ What is the difference, what business scenarios RabbitMQ is how to select the message queue

Redis data structure, hash hashmap key storage structure stored in the cluster

 

HTTP idempotency

Idempotent said: requests the server once or several times, the results returned are the same [select] usually GET request

Non-idempotent represented by: number of requests a different server, the returned result will be different [update delete] is generally POST request

 

 

 

What is the difference svn and git

Workflow contrast between the two:

svn mode

  1. write the code.
  2. From the server back to the server's current repository, and the repository server to resolve the conflict with the local code.
  3. The native code submitted to the server.

git mode

  1. write the code.
  2. Submitted to the local repository.
  3. From the server back to the server's current repository, and the repository server to resolve the conflict with the local code.
  4. The remote database and submit the results to the local code merge local repository.
  5. The local repository to push to the server.

Contrast can be seen: the distributed version management is only increasing the local library concept, and the rest is no different concept and centralized management. - but it can not be submitted with the svn server synchronization code before, thus modifying local problems more easily.

1. SVN advantages and disadvantages
advantages: 
1, easy management, logic clear, in line with the general thinking habits. 
2, easy to manage, centralized server to better ensure security. 
3, the code consistency is very high. 
4, for the development of the small number of project development. 
Disadvantages: 
1, the server too much pressure, database capacity surge. 
2, if not connected to the server, essentially you can not work, see the above second step, if the server can not connect, can not be submitted, reduction, contrast and the like. 
3, is not suitable for open source development (number of developing very, very much, but Google app engine is to use the svn). But there is a very clear rights management mechanisms (such as branch access restrictions) generally centralized management, hierarchical management can be achieved, so that a good solution to the large number of development issues.

 

2. Git advantages and disadvantages
advantages: 
1, suitable for distributed development, emphasis on the individual. 
2, public pressure and the amount of data the server will not be too large. 
3, fast, and flexible. 
4, can easily resolve any conflict between two developers. 
5, offline work. 
Disadvantages: 
1, the learning curve is relatively long. 
2, unconventional thinking. 
3, poor security codes, the entire library clones Once the developer down on full disclosure of all the code and version information.

 

Git poor security at this recent news, for example, Chinese programmers to upload live database connection to the hosting platform github, database password is too simple, seen from here is not only the cause of programmers, but also illustrates the Git reasons of poor security code.
 
 

 

 

Database common data types, float, double what's the difference, decimal floating-point precision problem solving

1. Integer:

'bit (Boolean): only enter true or false, an input is automatically converted into TRUE, 0 is automatically converted to FALSE

tinyint: only an integer from 0 to 225

smallint The (two bytes integers): - 32767 32768 ~

int (integer of four bytes): 31 th power of 2

BIGINT (eight bytes is an integer): th power of 2 63

2. currency:

money, possible four decimals

3. date type:

Data: 2001.1.1 ~ 9999.12.31

datatime: 1753.1.1 ~ 9999.12.31

Time: more precisely

4. character:

char (8000): a fixed length, a maximum of 8,000. Example char (10) can be saved 10 characters, 5 characters

nchar (4000): steady, 4000 is the maximum. Example nchar (10) can be saved 10 characters, 10 characters

varchar (8000): becomes long. Example varchar (10) only if the input 5, the only occupy 5, if it is char (10), only when the input 5

, the remaining 5 bits padded with zeros.

nvarchar (4000): variable length

 

float: single precision float

double: double precision floating

main differences are as follows:

  a different number of bytes occupied in memory 01.

    Single float in the local memory 4 bytes

    double precision machine memory accounted 8 bytes of

  different significant digits 02.

    single-precision floating-point number 8 effective bit

    double precision floating point 16-bit significant figures

  03. numerical range

    represents a range of single precision floating point: -3.40E + 38 ~ 3.40E + 38

    represents a double-precision floating-point range: -1.79E -1.79E + 308 + 308 ~

  04. in the program processing speed is different

    in general, CPU speed processing of single precision floating point double precision floating point more quickly than

if no declaration the default decimal type double, if you use a float, it must be strong turn

 

Use BigDecimal class provides java. Such encapsulated in java.math.BigDecimal

Such a configuration has many, but when using a floating-point type of computing device must be configured to use a String instance BigDecimal objects

 

Mysql index difference of Innodb MYISAM, b + tree storage structure, b tree

Two engines are used as a B + tree index data structure

difference:

1, INNODB must have a primary key, but also the clustered index, INNODB data file itself is an index file; and MYISAM is stored in the address data

2, secondary index INNODB, address stored primary key (it is recommended not to the length of the primary key is set too large, usually with auto-incremented number to), a secondary index search time, but also the first association to the primary key in the primary key query; and assistance with the primary key index MYISAM there is no difference, just a unique primary key, it is not unique secondary index.

3, INNODB support transactions; MYISAM does not support transactions

4, INNODB row locks; MYISAM table lock is

 

 

 

Scenarios, and implementation of optimistic and pessimistic locking

What is gc

tcp three-way handshake, http request process

What are commonly used design patterns, in what scenario under

Common time complexity of the algorithm

rdia persistence

redis cache coherency

Virtual Memory

Process Isolation

Database isolation level

Generic principles of the java (ArrayList <string> and ArrayList <integer>)

Generic nature of the parameter type, data type that is being operated is specified as a parameter. This parameter type may be used in the creation of classes, interfaces and methods, generic class, generic interfaces, generic methods are called.

Casts can be eliminated generic code, while obtaining an additional check type layer, the layer can be prevented check was wrong type of keys or values ​​stored in a collection. This is the generic work done.

 

Guess you like

Origin www.cnblogs.com/ashin1997/p/11603002.html