精华内容
下载资源
问答
  • Global Variables The behaviour of ProxySQL can be tweaked 调整 using global variables. These can be ...
    Global Variables
    The behaviour of ProxySQL can be tweaked 调整 using global variables. These can be configured in 2 ways:
    • at runtime, using the admin interface (preferred)
      • at startup, using the dedicated section in the configuration file
    ProxySQL supports maximal uptime by allowing most variables to change at runtime and take effect immediately, without having to restart the daemon. There are only 2 variables that cannot be changed at runtime - mysql-threads and mysql-stacksize.   mysql-threads and mysql-stacksize. 这两个配置不能进行动态的修改

    Also, there are 2 types of global variables, depending on which part of ProxySQL they control:

    • admin variables, which control the behaviour of the admin interface. Their names begin with the token "admin-"
    • mysql variables, which control the MySQL functionality of the proxy. Their names begin with the token "mysql-"
    These global variables are stored in a per-thread fashion 方式  inside of the proxy in order to speed up access to them, as they are used extremely frequently. They control the behaviour of the proxy in terms of 依据 memory footprint 内存占用  or the number of connections accepted, and other essential 基本的 aspects. Whenever a LOAD MYSQL VARIABLES TO RUNTIME command is issued (see theconfiguration system documentation for details on that command), all the threads using the variables are notified that they have to update their values.

    修改变量后需要进行load :   LOAD MYSQL VARIABLES TO RUNTIME;修改后,所有用到变量的线程都会刷新它们的值  
    注意 下面的管理的变量修改要使用   LOAD ADMIN VARIABLES TO RUNTIME,否则不能生效

    To change the value of a global variable either use an UPDATE statement:

    UPDATE global_variables SET variable_value=1900 WHERE variable_name='admin-refresh_interval'; 

    or the shorter SET statement, similar to MySQL's:

    SET admin-refresh_interval = 1700;
    SET admin-version = '1.1.1beta8'; 

    Next, we're going to explain each type of variable in detail.

    Admin Variables

    admin-admin_credentials

    This is a colon 冒号 separated user:password pair, that can be used to authenticate to the admin interface with read-write rights. For read-only credentials that can be used to connect to the admin, see the variable admin-stats_credentials. Note that the admin interface listens on a separate port from the main ProxySQL thread. This port is controlled through the variable admin-mysql_ifaces.
    Default value: admin:admin.  管理账户的默认配置就是 admin:admin 可以在这里进行自定义  修改成为自己定义的用户名密码 提高安全性

    admin-mysql_ifaces
    Semicolon 分号 -separated list of hostname:port entries for interfaces on which the admin interface should listen on. Note that this also supports UNIX domain sockets for the cases where the connection is done from an application on the same machine.
    Default value: 127.0.0.1:6032.
    Example: SET admin-mysql_ifaces='127.0.0.1:6032;/tmp/proxysql_admin.sock'  可以修改不用默认的端口 

    admin-read_only 打开后proysql就是只读模式,不能对proxysql进行修改了 不是不能通过proxysql进行查询
    When this variable is set to true and loaded at runtime, the Admin module does not accept write anymore. This is useful to ensure that ProxySQL is not reconfigured. When admin-read_only=true, the only way to revert it to false at runtime (and make the Admin module writable again) is to run the command PROXYSQL READWRITE. 解除proxysql的只读 执行  PROXYSQL READWRIT 命令就行

    Default value: false

    admin-refresh_interval 统计状态的时间间隔 默认两秒 不修改

    The refresh interval (in microseconds) for updates to the query rules statistics and commands counters statistics. Be careful about tweaking this to a value that is:

    • too low, because it might affect the overall performance of the proxy
    • too high, because it might affect the correctness of the results

    Default value: 2000 (microseconds)


    admin-stats_credentials    mysql -P6038 -h 127.0.0.1 -ustats -pstats 默认查看stats库里面的内容 也可以进行自定义 
    The read-only credentials for connecting to the admin interface. These are not allowed updates to internal data structures such as the list of MySQL backend servers (or hostgroups), query rules, etc. They only allow readings from the statistics and monitoring tables (the other tables are not only even visible).
    Default value: stats:stats   监控proxysql的账户

    admin-telnet_admin_ifaces

    Not currently used (planned usage in a future version).

    admin-telnet_stats_ifaces

    Not currently used (planned usage in a future version).

    admin-version

    This variable displays ProxySQL version. This variable is read only.

    MySQL Variables

    mysql-client_found_rows

    When set to true, client flag CLIENT_FOUND_ROWS is set when connecting to MySQL backends.

    Default value: true

    mysql-commands_stats

    Enable per-command MySQL query statistics. A command is a type of SQL query that is being executed. Some examples are: SELECT, INSERT or ALTER TABLE. See the stats_mysql_commands_counters section in the admin tables documentation in order to see more details about what kind of statistics are gathered.

    Default value: true

    mysql-connect_retries_delay

    The delay (in milliseconds) before trying to reconnect after a failed attempt to a backend MySQL server. Failed attempts can take place due to numerous reasons: too busy, timed out for the current attempt, etc. This will be retried for mysql-connect_retries_on_failure times.

    Default value: 1 (milliseconds)


    mysql-connect_retries_on_failure
    The number of times for which a reconnect should be attempted in case of an error, timeout, or any other event that led to an unsuccessful connection to a backend MySQL server. After the number of attempts is depleted 废弃的, if a connection still couldn't be established, an error is returned. The error returned is either the last connection attempt error or a generic error ("Max connect failure while reaching hostgroup" with error code 28000).

    Be careful about tweaking this parameter - a value that is too high can significantly increase the latency which with an unresponsive 反应迟钝的 hostgroup is reported to the MySQL client.

    Default value: 5 (reconnect times)

    mysql-connect_timeout_server

    The timeout for a single attempt at connecting to a backend server from the proxy. If this fails, according to the other parameters, the attempt will be retried until too many errors per second are generated (and the server is automatically shunned) or until the final cut-off is reached and an error is returned to the client (see mysql-connect_timeout_server_max).

    Default value: 1000 (miliseconds, the equivalent of 1 second)

    mysql-connect_timeout_server_max

    The timeout for connecting to a backend server from the proxy. When this timeout is reached, an error is returned to the client with code #28000 and the message "Max connect timeout reached while reaching hostgroup...".

    Default value: 10000 (miliseconds, the equivalent of 10 seconds)

    mysql-connection_max_age_ms

    When mysql-connection_max_age_ms is set to a value greater than 0, inactive connections in the connection pool (therefore not currently used by any session) are closed if they were created more than mysql-connection_max_age_ms milliseconds ago. By default, connections aren't closed based on their age.

    Default value: 0 (milliseconds)

    mysql-default_charset

    The default server charset to be used in the communication with the MySQL clients. Note that this is the defult for client connections, not for backend connections.

    Default value: utf8

    mysql-default_max_latency_ms

    ProxySQL uses a mechanism to automatically ignore hosts if their latency is excessive. Note that hosts are not disabled, but only ignored: in other words, ProxySQL will prefer hosts with a smaller latency. It is possible to configure the maximum latency for each backend from mysql_users table, column max_latency_ms. If mysql_users.max_latency_ms is 0, the default valuemysql-default_max_latency_ms applies.

    Default: 1000 (millisecond)

    Note: due to a limitation in SSL implementation, it is recommended to increase mysql-default_max_latency_ms if using SSL.、
    ssl 将会导致mysql的运行速度减慢

    mysql-default_query_delay

    Simple throttling mechanism for queries to the backends. Setting this variable to a non-zero value (in miliseconds) will delay the execution of all queries, globally. There is a more fine-grained throttling mechanism in the admin table mysql_query_rules, where for each rule there can be one delay that is applied to all queries matching the rule. That extra delay is added on top of the default, global one.

    Default value: 0 (miliseconds)

    mysql-default_query_timeout

    Mechanism for specifying the maximal duration of queries to the backend MySQL servers until ProxySQL should return an error to the MySQL client. Whenever ProxySQL detects that a query has timed out, it will spawn 引起 a separate thread that runs a KILL query against the specific MySQL backend in order to stop the query from running in the backend. Because the query is killed, an error will be returned to the MySQL client.

    Default value: 86400000 (miliseconds - the equivalent of 1 day = 24 hours)

    mysql-default_reconnect

    Not used for now.

    mysql-default_schema

    The default schema to be used for incoming MySQL client connections which do not specify a schema name. This is required because ProxySQL doesn't allow connection without a schema.

    Default value: information_schema


    mysql-enforce_autocommit_on_reads  通过rules实现读写分离的同事开启自动提交,是会导致一些问题的

    ProxySQL tracks the status of autocommit as specified by the client, and ensures that autocommit is set correct on backend connections. This implementation is problematic 有问题的 if a client starts a transaction using autocommit, and read/write split is implemented via query rules. In fact, if a read is sent to a slave and ProxySQL sets autocommit=0 on slave, this will result in 2 transactions (one on master and one on slave). To prevent this to happen, if mysql-enforce_autocommit_on_reads=false (the default), ProxySQL won't change the value of autocommit on backend connections for SELECT stataments.

    Default value: false


    mysql-eventslog_filename 记录proxysql的日志的目录

    If this variable is set, ProxySQL will log all traffic to the specified filename. Note that the log file is not a text file, but a binary log with encodided traffic.

    Default value: empty string, not set

    mysql-eventslog_filesize proxusql日志文件的大小限制

    This variable specifies the maximum size of files created by ProxySQL logger as specified in mysql-eventslog_filename. When the maximum size is reached, the file is rotated.

    Default value: 104857600 (100MB)

    mysql-free_connections_pct proxysql提供连接池到后台的mysql 这个参数控制其中空闲的查询的占比

    ProxySQL uses a connection pool to connect to backend servers. As part of this, it sometimes decides to keep some connections open and ready to use for future queries. It does this by pinging them once in a while. This variable controls the percentage of open idle connections from the total maximal number of connections open to that server.

    A connection is idle if it hasn't used since the last round of pings. The time interval between two such rounds of pings for idle connections is controlled by the variable mysql-processing_idles.

    Default value: 10 (percent)

    mysql-have_compress

    Currently unused.

    mysql-interfaces

    The TCP interfaces on which ProxySQL should listen for incoming MySQL traffic. As is obvious from the default value, this also supports UNIX sockets for faster local traffic.

    Default value: 0.0.0.0:6033;/tmp/proxysql.sock

    mysql-long_query_time

    Threshold for counting queries passing through the proxy as 'slow'. The total number of slow queries can be found in thestats_mysql_global table, in the variable named Slow_queries (each row in that table represents one variable).

    Default value: 1000 (ms)

    mysql-max_connections

    The maximal number of TCP connections that the proxy can handle. After this number is reached, new connections will be rejected with the #HY000 error, and the error message Too many connections.

    Default value: 10000 (connections)

    mysql-max_transaction_time

    Sessions with active transactions running more than this timeout are killed.
    Default value: 14400000 (miliseconds - the equivalent of 4 hours)  4个小时是合理的设置 已经太长了

    mysql-monitor_connect_interval

    The interval at which the Monitor module of the proxy will try to connect to all the MySQL servers in order to check whether they are available or not.

    Default value: 120000 (miliseconds - the equivalent of 2 minutes) 2分钟对mysql servers 做一次检测

    mysql-monitor_connect_timeout

    Connection timeout in milliseconds. The current implementation rounds this value to an integer number of seconds less or equal to the original interval, with 1 second as minimum. This lazy  rouding is done because SSL connections are blocking calls.

    Default value: 200 (miliseconds)

    mysql-monitor_enabled

    It enables or disables MySQL Monitor.

    Defaut value: true

    mysql-monitor_history

    The duration for which the events for the checks made by the Monitor module are kept. Such events include connecting to backend servers (to check for connectivity issues), querying them with a simple query (in order to check that they are running correctly) or checking their replication lag. These logs are kept in the following admin tables:

    • mysql_server_connect_log
    • mysql_server_ping_log
    • mysql_server_replication_lag_log

    Default value: 600000 (miliseconds - the equivalent of 100 seconds)

    mysql-monitor_username, mysql-monitor_password

    The (username, password) combination with which the Monitor module will connect to the backend servers in order to check their health. Note that ProxySQL does not make any automated decisions based on these checks, but the data can be used in external scripts.

    It is also very important to note that mysql-monitor_username must not be a user in mysql_users table. Although, ProxySQL does not enforce this restriction.

    Default values: monitor / monitor

    mysql-monitor_ping_interval

    The interval at which the Monitor module should ping the backend servers by using the mysql_ping API.

    Default value: 60000 (miliseconds, the equivalent of 1 minute)

    mysql-monitor_ping_timeout

    Currently unused.

    Default value: 100 (miliseconds)

    mysql-monitor_query_interval

    Currently unused. Will be used by the Monitor module in order to collect data about the global status of the backend servers.

    Default value: 60000 (miliseconds, the equivalent of 1 minute)

    mysql-monitor_query_status

    Currently unused. Will be used by the Monitor module in order to collect data about the global status of the backend servers.

    Default value: SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS

    mysql-monitor_query_timeout

    Currently unused. Will be used by the Monitor module in order to collect data about the global status of the backend servers.

    Default value: 100 (miliseconds)

    mysql-monitor_query_variables

    Currently unused. Will be used by the Monitor module in order to collect data about the global status of the backend servers.

    Default value: SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

    mysql-monitor_replication_lag_interval

    The interval at which the proxy should connect to the backend servers in order to monitor the replication lag between those that are slaves and their masters. Slaves can be temporarily shunned if the replication lag is too large. This setting is controlled by themysql_servers.max_replication_lag column in the admin interface, at a per-hostgroup level.

    Default value: 10000 (miliseconds, the equivalent of 10 seconds)

    mysql-monitor_replication_lag_timeout

    Currently unused.

    Default value: 1000 (miliseconds)

    mysql-monitor_timer_cached

    This variable controls whether ProxySQL should use a cached (and less accurate) value of wall clock time, or not. The actual API used for this is described here.

    Default value: true

    mysql-ping_interval_server_msec

    The interval at which the proxy should ping backend connections in order to maintain them alive, even though there is no outgoing traffic. The purpose here is to keep some connections alive in order to reduce the latency of new queries towards a less frequently used destination backend server.

    Default value: 10000 (miliseconds, the equivalent of 10 seconds)

    mysql-ping_timeout_server

    The proxy internally pings the connections it has opened in order to keep them alive. This elliminates 消除 the cost of opening a new connection towards a hostgroup when a query needs to be routed, at the cost of additional memory footprint inside the proxy and some extra traffic. This is the timeout allowed for those pings to succeed.

    Default value: 200 (miliseconds)

    mysql-poll_timeout

    The minimal timeout used by the proxy in order to detect incoming/outgoing traffic via the poll() system call. If the proxy determines that it should stick to a higher timeout because of its internal computations, it will use that one, but it will never use a value less than this one.

    Default value: 2000 (miliseconds, the equivalent of 2 seconds)

    mysql-poll_timeout_on_failure

    The timeout used in order to detect incoming/outgoing traffic after a connection error has occured. The proxy automatically tweaks its timeout to a lower value in such an event in order to be able to quickly respond with a valid connection.

    Default value: 100 (miliseconds)

    mysql-query_digests

    When this variable is set to true, the proxy analyzes the queries passing through it and divides them into classes of queries having different values for the same parameters. It computes a couple of metrics for these classes of queries, all found in thestats_mysql_query_digest table. For more details, please refer to the admin tables documentation.

    Default value: true (query digests are enabled)

    mysql-server_capabilities

    The bitmask 位掩码 of MySQL capabilities (encoded as bits) with which the proxy will respond to clients connecting to it. This is useful in order to prevent certain features from being used. The default capabilities are:

    server_capabilities = CLIENT_FOUND_ROWS | CLIENT_PROTOCOL_41 | CLIENT_IGNORE_SIGPIPE | CLIENT_TRANSACTIONS | CLIENT_SECURE_CONNECTION | CLIENT_CONNECT_WITH_DB | CLIENT_SSL;
    

    More details about server capabilities in the official documentation.

    Default value: 47626

    mysql-server_version

    The server version with which the proxy will respond to the clients. Note that regardless of the versions of the backend servers, the proxy will respond with this.

    Default value: 5.5.30

    mysql-servers_stats

    Currently unused. Will be removed in a future version.

    Default value: true

    mysql-session_debug

    Currently unused. Will be removed in a future version.

    Default value: true

    mysql-sessions_sort

    Sessions are conversations 对话 between a MySQL client and a backend server in the proxy. Sessions are generally processed in a stable order but in certain scenarios (like using a transaction workload, which makes sessions bind to certain MySQL connections from the pool), processing them in the same order leads to starvation 饥饿.

    This variable controls whether sessions should be processed in the order of waiting time, in order to have a more balanced distribution of traffic among sessions.

    Default value: true

    mysql-shun_on_failures

    The number of connection errors tolerated to the same server within an interval of 1 second until it is automatically shunned temporarily. For now, this can not be disabled by setting it to a special value, so if you want to do that, you can increase it to a very large value.

    Default value: 5

    mysql-shun_recovery_time

    A backend server that has been automatically shunned will be recovered after at least this amount of time. Note that there is no actual hard guarantee of the exact timing, but in practice it shouldn't exceed this value by more than a couple of seconds.

    Default value: 10 (seconds)

    mysql-stacksize

    The stack size to be used with the background threads that the proxy uses to handle MySQL traffic and connect to the backends. Note that changing this value has no effect at runtime, if you need to change it you have to restart the proxy.

    Default value: 1048576 (bytes, the equivalent of 1 MB)

    mysql-threads

    The number of background threads that ProxySQL uses in order to process MySQL traffic. Note that there are other "administrative" threads on top of these, such as:

    • the admin interface thread
    • the monitoring module threads that interact with the backend servers (one for monitoring connectivity, one for pinging the servers and one for monitoring the replication lag)
    • occasional temporary threads created in order to kill long running queries that have become unresponsive
    • background threads used by the libmariadbclient library in order to make certain interactions with MySQL servers async

    Note that changing this value has no effect at runtime, if you need to change it you have to restart the proxy.

    Default value: 4 (background threads to process MySQL traffic)

    mysql-threshold_query_length

    The maximal size of an incoming SQL query to the proxy that will mark the background MySQL connection as non-reusable. This will force the proxy to open a new connection to the backend server, in order to make sure that the memory footprint of the server stays within reasonable limits.

    More details about it here: https://dev.mysql.com/doc/refman/5.6/en/memory-use.html

    Relevant quote from the mysqld documentation: "The connection buffer and result buffer each begin with a size equal to net_buffer_length bytes, but are dynamically enlarged up to max_allowed_packet bytes as needed. The result buffer shrinks to net_buffer_length bytes after each SQL statement."

    Default value: 524288 (bytes, the equivalent of 0.5 MB)

    mysql-threshold_resultset_size

    If a resultset returned by a backend server is bigger than this, proxysql will start sending the result to the MySQL client that was requesting the result in order to limit its memory footprint.

    Default value: 4194304 (bytes, the equivalent of 4 MB)

    mysql-wait_timeout

    If a proxy session (which is a conversation between a MySQL client and a backend MySQL server) has been idle for more than this threshold, the proxy will kill the session.

    Default value: 28800000 (miliseconds, the equivalent of 8 hours)


    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29291882/viewspace-2133181/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/29291882/viewspace-2133181/

    展开全文
  •  variables that are available inside your script. Also, the  _editor  variable is available inside the script. This variable is bound to the current editor. JsArrayVariable() ...

    Live Template

    用中文应该叫做热加载模板。它的原理就是配置一些常用代码字母缩写,在输入简写时可以出现你预制的模板内容,使得开发效率大大提高。


    Webstorm js中,自定义js说明注释(文档描述、作者、创建日期等): 
    快捷键 Ctrl + Shift + S 打开Webstorm设置,搜索‘Live Template’,找到JavaScript,如下:

    è¿éåå¾çæè¿°

    点击右上角“+”-> Live Template,添加注释模板,出现以下界面,填写相关的信息: 

    下面我要介绍的是 Edit variables

     

    Predefined Functions to Use in Live Template Variables  的参数如下:

    Item

    Description

    blockCommentEnd

    Returns the characters that indicate the end of a block comment in the current language context.返回指示当前语言上下文中块注释结尾的字符。

    blockCommentStart

    Returns the characters that indicate the start of a block comment in the current language context.返回指示当前语言上下文中块注释开头的字符。

    camelCase(String)

    Converts a string into camelCase. For example, camelCase(my-text-file)camelCase(my text file), and camelCase(my_text_file) all return myTextFile.

    将字符串转换为驼色大小写。例如, camelCase(my-text-file), camelCase(my text file), and camelCase(my_text_file) 这三种都返回 myTextFile.

    capitalize(String)

    Capitalizes the first letter of the parameter.

    将参数的第一个字母大写。

    capitalizeAndUnderscore(sCamelCaseName)

    Capitalizes all the letters of a CamelCase name passed as the parameter, and inserts an underscore between the parts. For example, capitalizeAndUnderscore(FooBar) returnsFOO_BAR.

    将参数所有字母大写,并在各部分之间插入下划线。例如,如capitalizeAndUnderscore(FooBar),返回FOO_BAR

    classNameComplete()

    This expression substitutes for the class name completion at the variable position.

    此表达式在变量位置替换类名完成。

    clipboard()

    Returns the contents of the system clipboard.

    返回系统剪贴板的内容。

    commentEnd()

    Returns the characters that indicate the end of a comment in the current language context. The return value is empty if line comments are defined in the current language.

    返回指示当前语言上下文中注释结尾的字符。如果行注释是用当前语言定义的,则返回值为空。

    commentStart()

    Returns the characters that indicate the start of a comment in the current language context. If line comments are defined in the current language, their start indicator is preferable.

    返回指示当前语言上下文中注释开头的字符。如果行注释是用当前语言定义的,则它们的开始指示符更可取。

    complete()

    Invokes code completion at the position of the variable.

    在变量的位置自动识别代码

    completeSmart()

    Invokes smart type completion at the position of the variable.

    在变量的位置调用智能类型完成。

    concat(expressions...)

    Returns a concatenation of all the strings passed to the function as parameters.

    返回串联的所有参数

    dartIterableVariable()

    Returns the name of a variable that can be iterated.

    返回可迭代的变量的名称。

    dartListVariable()

    Returns a list of elements of an array.

    返回数组元素的列表。

    dartSuggestIndexName()

    Returns a suggested name for an index variable from most commonly used ones: ijk, etc. The names that are not used in the current scope yet are shown first.

    回最常用的索引变量的建议名称:i、j、k等。当前作用域中尚未使用的名称将首先显示。

    dartSuggestVariableName()

    Returns the suggested name for a variable based on its variable type and initializer expression, according to your code style settings that refer to the variable naming rules.
    For example, if it is a variable that holds an element within an iteration, WebStorm makes a guess on the most reasonable name, taking into account the name of the container that is iterated.

    date(sDate)

    Returns the current system date in the specified format.

    Without a parameter, the current date is returned in the default system format.

    以指定格式返回当前系统日期。

    如果没有参数,则以默认系统格式返回当前日期。

    decapitalize(sName)

    Replaces the first letter of the parameter with the corresponding lowercase letter.

    将参数的第一个字母替换为相应的小写字母。

    enum(sCompletionString1,sCompletionString2,...)

    Returns a list of comma-separated strings suggested for completion when the template is expanded.

    返回在扩展模板时建议完成的逗号分隔字符串列表。

    escapeString(sEscapeString)

    Escapes the string specified as the parameter.

    转义指定为参数的字符串。

    expectedType()

    Returns the expected type of the expression into which the template expands. Makes sense if the template expands in the right part of an assignment, after return, etc.

    当模板扩展中返回表达式的预期类型,如果模板在分配的正确部分、返回后等进行扩展,则是有意义的。

    fileName()

    Returns the name of the current file with its extension.

    返回当前文件的名称及其扩展名。

    fileNameWithoutExtension()

    Returns the name of the current file without its extension.

    返回不带扩展名的当前文件的名称。

    firstWord(sFirstWord)

    Returns the first word of the string passed as the parameter.

    返回作为参数传递的字符串的第一个字。

    groovyScript("groovy code", arg1)

    Returns a Groovy script with the specified code.

    You can use the groovyScript() function with multiple arguments. The first argument is the text of the script that is executed or the path to the file that contains the script. The next arguments are bound to the _1_2_3, ..._n variables that are available inside your script. Also, the _editor variable is available inside the script. This variable is bound to the current editor.

    JsArrayVariable()

    Returns the name of the current JavaScript array.

    jsClassName()

    Returns the name of the current JavaScript class.

    返回当前javascript类的名称。

    jsComponentTypeOf()

    Returns the type of the current JavaScript component.

    返回当前javascript组件的类型。

    jsDefineParameter

    Based on the name of the module, returns the parameter fromdefine(["module"], function (<parameter_in_question>>) {}).

    根据模块的名称,返回参数fromdefine([“module”]、function(<parameter_in_question>>))。

    jsMethodName()

    Returns the name of the current JavaScript method.

    返回当前javascript方法的名称。

    jsQualifiedClassName()

    Returns the complete name of the current JavaScript class.

    jsSuggestIndexName()

    Returns a suggested name for an index variable from most commonly used ones: ijk, etc. The names that are not used in the current scope yet are shown first.

    jsSuggestVariableName()

    Returns the suggested name for a variable based on its variable type and initializer expression, according to your code style settings that refer to the variable naming rules.
    For example, if it is a variable that holds an element within an iteration, WebStorm makes a guess on the most reasonable name, taking into account the name of the container that is iterated.

    jsSuggestDefaultVariableKind(Boolean)

    The Boolean parameter determines whether constants are allowed or not in the current context. If no parameter is specified, constants are allowed. When the templates expands, a drop-down list is shown with varletconst options for TypeScript and ES6 and with only one var option for earlier JavaScript versions.

    jsSuggestImportedEntityName()

    Suggests the name for import statements of the type`import * as $ITEM$ from "$MODULE$"` or `import $ITEM$ from "$MODULE$"` based on the file name.

    lineCommentStart

    Returns the characters that indicate the start of a line comment in the current language context.

    返回在当前语言上下文中指示行注释开头的字符。

    lineNumber()

    Returns the current line number.

    返回当前行号。

    lowercaseAndDash(String)

    Converts a camelCase string into lower case and inserts n-dashes as separators. For example, lowercaseAndDash(MyExampleName) returns my-example-name.

    字符串转换为小写,并插入n个-作为分隔符,例如 lowercaseAndDash(MyExampleName) returns my-example-name

    snakeCase(String)

    Converts a string into snake_case. For example, snakeCase(fooBar) returns foo_bar.

    将字符串转换为蛇形命名法。例如,snakecase(foo bar)返回foo_bar。

    spaceSeparated(String)

    Converts a string into lowercase and inserts spaces as separators. For example, spaceSeparated(fooBar) returns foo bar.

    将字符串转换为小写并插入空格作为分隔符。例如,spaceseparated(foo bar)返回foo bar。

    substringBefore(String,Delimiter)

    Removes the extension after the specified delimiter and returns only the file name. This is helpful for test file names (for example, substringBefore($FileName$,".") returns component-test in component-test.js).

    删除指定分隔符后的扩展名,并仅返回文件名。这有助于测试文件名(例如,$filename$,“.”之前的子字符串)返回component test in component test.js。

    time(sSystemTime)

    Returns the current system time in the specified format.

    以指定格式返回当前系统时间。

    underscoresToCamelCase(String)

    Replaces underscores with camelCase letters in the string passed as the parameter. For example, underscoresToCamelCase(foo_bar) returns fooBar.

    替换下划线。例如,underlinestocamelcase(foo_bar)返回foo bar。

    underscoresToSpaces(sParameterWithUnderscores)

    Replaces underscores with spaces in the string passed as the parameter. For example, underscoresToSpaces(foo_bar) returns foo bar.

    将参数中的下划线替换成空格,如underscoresToSpaces(foo_bar)返回foo bar

    user()

    Returns the name of the current user.

    返回当前用户的名称。

    展开全文
  • Blocks and Variables https://developer.apple.com/library/ios/documentation/cocoa/conceptual/Blocks/Articles/bxVariables.html http://stackoverflow.com/questions/16149653/what-is-...

    Blocks and Variables

    https://developer.apple.com/library/ios/documentation/cocoa/conceptual/Blocks/Articles/bxVariables.html

    http://stackoverflow.com/questions/16149653/what-is-the-role-of-the-copy-in-the-arc

     

    This article describes the interaction between blocks and variables, including memory management.

    这篇文章描述了 blocks 与变量间的交互作用,同时也包括内存管理。

     

    Types of Variable

    Within the block object’s body of code, variables may be treated in five different ways.

    在 block 对象体中插入的代码,变量可以分为5种。

    You can reference three standard types of variable, just as you would from a function:

    你可以引用 3 种标准类型的变量,就像你在普通方法中使用的那样子:

    • Global variables, including static locals  全局变量,包括 static 修饰过的静态变量

    • Global functions (which aren’t technically variables) 全局方法(技术上来说不能被称作变量)

    • Local variables and parameters from an enclosing scope 局部变量和从上下文中带进来的参数

    Blocks also support two other types of variable:

    Blocks 也支持另外两种类型的变量:

    1. At function level are __block variables. These are mutable within the block (and the enclosing scope) and are preserved if any referencing block is copied to the heap. 函数级别上的 __block 修饰的对象。它在block里面是可以修改的,如果这个 block 被 copy 到了栈区,这个对象就会被强引用。

    2. const imports. const引入的。

    Finally, within a method implementation, blocks may reference Objective-C instance variables—see “Object and Block Variables.”

    最终,在一个方法的实现当中,blocks 也许会强引用 Objective-C 实例变量,请参考  “Object and Block Variables.” 

    The following rules apply to variables used within a block:

    以下规则适用于在 block 中使用的变量:

    1. Global variables are accessible, including static variables that exist within the enclosing lexical scope. 可以接收全局变量,包括存在于上下文中的静态变量。

    2. Parameters passed to the block are accessible (just like parameters to a function). 传递到 block 中的变量(就像函数传递参数一样)

    3. Stack (non-static) variables local to the enclosing lexical scope are captured as const variables. 相对于 block 块的非静态堆区对象被识别为 const 对象。

      Their values are taken at the point of the block expression within the program. In nested blocks, the value is captured from the nearest enclosing scope.  他们的值会以指针的形式传递到 block 中。

    4. Variables local to the enclosing lexical scope declared with the __block storage modifier are provided by reference and so are mutable.  __block 修饰的对象允许在 block 中进行修改,并会被 block 强引用。

      Any changes are reflected in the enclosing lexical scope, including any other blocks defined within the same enclosing lexical scope. These are discussed in more detail in “The __block Storage Type.”

    5. Local variables declared within the lexical scope of the block, which behave exactly like local variables in a function. 在 block 块中实例化的对象,与在函数中实例化的对象基本一致。

      Each invocation of the block provides a new copy of that variable. These variables can in turn be used as const or by-reference variables in blocks enclosed within the block. 每一次调用这个 block 都会提供一个变量的 copy。相应的,这些对象可以被当做 const 或者是强引用的对象使用。

    The following example illustrates the use of local non-static variables:

    以下例子描述了如何使用一个本地非 static 的变量:

    int x = 123;
     
    void (^printXAndY)(int) = ^(int y) {
     
        printf("%d %d\n", x, y);
    };
     
    printXAndY(456); // prints: 123 456

    As noted, trying to assign a new value to x within the block would result in an error:

    正如提到的那样,给 x 在 block 中直接赋值会引发错误:

    int x = 123;
     
    void (^printXAndY)(int) = ^(int y) {
     
        x = x + y; // error
        printf("%d %d\n", x, y);
    };

    To allow a variable to be changed within a block, you use the __block storage type modifier—see “The __block Storage Type.”

    为了允许一个变量在 block 中可以被修改,你需要使用 __block 存储的类型,查看 “The __block Storage Type.”

     

    The __block Storage Type

    You can specify that an imported variable be mutable—that is, read-write— by applying the __block storage type modifier. __block storage is similar to, but mutually exclusive of, the registerauto, and static storage types for local variables.

    你可以指定引入的对象可以被修改,那就是,可读可写。通过给这个变量修饰 __block 存储修改类型。__block 存储与 register ,auto,static 存储方式互斥(对于一个别修饰的变量)。

    __block variables live in storage that is shared between the lexical scope of the variable and all blocks and block copies declared or created within the variable’s lexical scope. Thus, the storage will survive the destruction of the stack frame if any copies of the blocks declared within the frame survive beyond the end of the frame (for example, by being enqueued somewhere for later execution). Multiple blocks in a given lexical scope can simultaneously use a shared variable.

    __block 变量在一个容器中存活,可以被变量的上下文共享,可以被所有 block 共享,可以被 copy 修饰过的 block 共享,以及在 block 块中创建的对象共享。也就是说,如果有任何 copy 出来的 block 用了这个变量,它会一直存活于堆区当中。

    As an optimization, block storage starts out on the stack—just like blocks themselves do. If the block is copied using Block_copy (or in Objective-C when the block is sent a copy), variables are copied to the heap. Thus, the address of a __block variable can change over time.

    作为一个优化,block 存储开始与堆区,就像 blocks 他们自己做的那样子。如果这个 block 被 copy 了(或者在 OC 当中 block 接收到了 copy 消息)。变量就会被复制到栈区去。也就是说,这个变量可以一直被修改了。

    There are two further restrictions on __block variables: they cannot be variable length arrays, and cannot be structures that contain C99 variable-length arrays.

    对于 __block 变量有着两点限制:他们不能用于可变长度的数组,也不能包括C99中可变长度数组的结构体。

    The following example illustrates use of a __block variable:

    以下例子描述了怎么使用 __block 变量:

    __block int x = 123; //  x lives in block storage
     
    void (^printXAndY)(int) = ^(int y) {
     
        x = x + y;
        printf("%d %d\n", x, y);
    };
    printXAndY(456); // prints: 579 456
    // x is now 579

    The following example shows the interaction of blocks with several types of variables:

    以下例子显示了 blocks 如何与不同类型的变量交互:

    extern NSInteger CounterGlobal;
    static NSInteger CounterStatic;
     
    {
        NSInteger localCounter = 42;
        __block char localCharacter;
     
        void (^aBlock)(void) = ^(void) {
            ++CounterGlobal;
            ++CounterStatic;
            CounterGlobal = localCounter; // localCounter fixed at block creation
            localCharacter = 'a'; // sets localCharacter in enclosing scope
        };
     
        ++localCounter; // unseen by the block
        localCharacter = 'b';
     
        aBlock(); // execute the block
        // localCharacter now 'a'
    }
    展开全文
  • Blocks和Variables

    2012-08-19 23:53:42
    翻译不不到位之处,请指正,建议点击上面链接看苹果官网介绍。 本文描述的是Blocks和Variables之间的交互,包括内存管理部分。 1. 变量类型 在block对象的函数体中,变量可能会以5中不同的方式做处理。 你可以...

    译自:Blocks and Variables

    翻译不不到位之处,请指正,建议点击上面链接看苹果官网介绍。

    本文描述的是Blocks和Variables之间的交互,包括内存管理部分。

    1. 变量类型

    在block对象的函数体中,变量可能会以5中不同的方式做处理。

    你可以引用三种标准类型的变量:

    。全局变量,包括静态的本地变量

    。全局函数(which aren’t technically variables)

    。局部变量和闭合作用域内的参数

    blocks也支持另外两种类型的变量:

    。At function level are__block variables. These are mutable within the block (and the enclosing scope) and are preserved if any referencing block is copied to the heap.

    const imports.

    最后在函数的实现中,blocks可能会引用Objective-C的实例变量。

    下面的规则适用于在block内使用的变量:

    。可访问全局变量,包括静态变量

    。可访问传向block的参数,就跟函数一样

    。闭合词法作用域内的堆栈(非静态)变量被视作const变量。它们的值在程序内的block表达式内获取,对于嵌套的blocks,该值从最近的闭合作用域内获取

    。使用 __block 存储标识符声明的闭合词法作用域内的变量是通过引用提供的,所以该变量是可变的。对该变量的任何改变都可反馈到词法作用域内,包括在同一词法作用域内定义的任何其他blocks

    。block的词法作用域内定义的局部变量,同函数内的局部变量完全一样。每次对block的调用都会有该变量的一个新拷贝,These variables can in turn be used asconst or by-reference variables in blocks enclosed within the block.

    下面的例子演示了局部非静态变量的用法:

    int x = 123;
     
    void (^printXAndY)(int) = ^(int y) {
     
        printf("%d %d\n", x, y);
    };
     
    printXAndY(456); // prints: 123 456

    上例中,block内可直接访问变量 x,并且 x 被视作 const 类型,如果在block内尝试改变 x 的值会报错:

    int x = 123;
     
    void (^printXAndY)(int) = ^(int y) {
     
        x = x + y; // error
        printf("%d %d\n", x, y);
    };

    为了允许一个变量能够在block内改变它,你可以使用 __block 存储类型标示符。

    2. __block 存储类型

    可以使用 __block 存储类型标示符指定一个重要的变量可变(也就是可读可写),__block存储同局部变量的register,auto,static存储类型相似,但是不能同它们同时使用。

    __block变量在存储区中存储,该存储区共享于 变量的词法作用域 及 在变量的词法作用域中声明和创建的blocks和blocks副本中。如果在堆栈框架中声明的blocks的任一副本在该堆栈框架被销毁后依然存在,那么该__block变量的存储区依然存在(例如,blocks在排队队列中等待执行)。在同一词法作用域中的多个blocks可以同时使用一个共享变量。

    作为一种优化处理,blocks存储区就和blocks本身一样会跳出堆栈。当使用Block_copy(或者在Objective-C中,向block发送copy消息)复制block后,变量被拷贝到堆中。于是随着时间的改变,block变量的地址也可能改变。

    使用__block变量有两个限制条件:它们不能是可变长度数组,不能是包含C99可变长度数组的结构。

    下面的例子展示了__block变量的使用方法:

    __block int x = 123; //  x lives in block storage
     
    void (^printXAndY)(int) = ^(int y) {
     
        x = x + y;
        printf("%d %d\n", x, y);
    };
    printXAndY(456); // prints: 579 456
    // x is now 579

    下面的例子展示了blocks和几种类型的变量的交互。

    extern NSInteger CounterGlobal;
    static NSInteger CounterStatic;
     
    {
        NSInteger localCounter = 42;
        __block char localCharacter;
     
        void (^aBlock)(void) = ^(void) {
            ++CounterGlobal;
            ++CounterStatic;
            CounterGlobal = localCounter; // localCounter fixed at block creation
            localCharacter = 'a'; // sets localCharacter in enclosing scope
        };
     
        ++localCounter; // unseen by the block
        localCharacter = 'b';
     
        aBlock(); // execute the block
        // localCharacter now 'a'
    }

    3。对象和block变量

    Objective-C对象

    在手动的引用计数环境,当blocks被复制时,在block中使用的局部变量会被保留(retain), 在block中使用实例变量会导致包含该实例变量的对象本身被保留(retain),如果你想为一特定的对象变量重载这一行为,可以使用__block存储类型标识符标记该变量。

    如果你使用ARC,block被复制或者释放时,对象变量会被自动被retain或者release。

    如果在函数的实现中使用了block,对象实例变量的内存管理规则更加精细:

    。如果通过引用访问实例变量, self 将会被retain

    。如果通过值访问实例变量,该变量将会被retain

    下面的例子展示了上面两种不同的情况:

    dispatch_async(queue, ^{
        // instanceVariable is used by reference, self is retained
        doSomethingWithObject(instanceVariable);
    });
     
     
    id localVariable = instanceVariable;
    dispatch_async(queue, ^{
        // localVariable is used by value, localVariable is retained (not self)
        doSomethingWithObject(localVariable);
    });

    C++对象

    通常情况下可以在block中使用C++对象。在成员函数中,是通过this指针来完成对成员变量或者成员函数的引用,并且该引用是可变的。当一个block被拷贝时需要考虑两种情况:

    。If you have a __block storage class for what would have been a stack-based C++ object, then the usual copy constructor is used.

    。If you use any other C++ stack-based object from within a block, it must have a const copy constructor. The C++ object is then copied using that constructor.


    Blocks

    当你拷贝一个block,有必要的话,在该block中引用的其他block会被拷贝。从头开始的整个树会被拷贝。如果你有block变量,并且你从该block变量中引用了一个block,那么这个被引用的block将会被拷贝。

    当你拷贝一个基于堆栈的block,将会获得一个新的block。当你拷贝一个基于堆的block,这只会简单的增加该block的引用计数,并且从拷贝函数或者方法的返回值获取该block。


    展开全文
  • 原文地址(翻译练手) 2017年12月14日 Defining and updating JavaScript variables in different scopes 昨天,我们学习了关于JavaScript作用域。今天,我们来学习如何去在不同类型的作用域中更新变量。 用前缀var来...
  • 文章目录数据(Data)重点对象和变量(Objects and variables)作者注变量实例化(Variable instantiation)数据类型(Data types)定义多个变量(Defining multiple variables)最佳实践小结 原文链接 数据(Data) ...
  • MySQL - 翻译 - 5.1 Reference Manual参考手册 - 5.1.3 Server System Variables服务器系统变量 - max_heap_table_sizemax_heap_table_sizeOption Sets Variable选项集变量Yes, max_heap_table_size是Variable Name...
  • Axure RP Pro - 翻译 - 5.5 Tutorial教程 - AXURE 202 Article 5: Rich Functionality复杂功能 - Variables - 变量Overview概述 1. Variables Demo 1. 变量演示 2. Variables 2. 变量 3. Managing
  • 本篇将会结合Unity3D官方文档对Unity3D内置参数或函数进行讲解及文档翻译。 本篇将会持续更新,更新结束后这一句话将会删除。 光照部分 本次讲解的内容为光照相关,因为我接下来的篇章将会对Unity3D光照相关的知识...
  • MySQL - 翻译 - 5.1 Reference Manual参考手册 - 5.1.3 Server System Variables服务器系统变量 - max_heap_table_sizemax_heap_table_sizeOption Sets Variable选项集变量Yes, max_heap_table_size是V
  • Javascript Variables

    2019-09-27 12:12:31
    要学好JS,要从基础学起。...用我有限的英文翻译了一点,不要恶心我。 1、Javascript变量作用域 JavaScript的变量作用域分为全局和局部两种。 代码 1 var scope = "global"; // 声明一个全局变量2 function...
  • 在此,结合自己的理解,稍作翻译与内容讲解,虽然都是英文的,但是木有想象中的难的,小伙子加油哈!本节知识点:(1)Python中global和local variables;(2)初识global关键字Global variables Global variables are ...
  • Axure RP Pro - 翻译 - 5.5 Tutorial教程 - AXURE 202 Article 5: Rich Functionality复杂功能 - Variables - 变量 Overview 概 述 1. Variables Demo 1. 变量演示 2. Variables 2. 变量 3. ...
  • GitLab CI/CD Variables 中文文档

    千次阅读 2019-06-27 18:29:00
    官方文档链接(这篇文章也算是翻译自官网文档): GitLab CI/CD environment variables 当GitLab CI 中接受到一个job后,Runner就开始准备构建环境。开始设置预定义的变量(环境变量)和用户自定义的变量。 variables...
  • 原文来源:MySQL 5.5 Reference Manual部分翻译取自:《MySQL_5.1中文参考手册》------------------------------------------------------------------------------------------Show variables在Show variables输出...
  • 这是萧荫堂的著作,由陈志华、钟家庆整理,陈志华翻译
  • 翻译变量提取器(Demo项目) 如何测试 见我的PR:
  • 可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):问题:I need to set some environment variables in the python script and I want all the other scripts that are...
  • 部分翻译取自:《MySQL_5.1中文参考手册》 转载请注明原文链接http://www.cnblogs.com/lenagt/archive/2012/06/06/2538227.html谢谢。 -----------------------------------------------------------------...
  • 本笔记参照TensorFlow官方教程,主要是对‘Tensor’教程内容翻译和内容结构编排,原文链接:Variables 目录 一、创建变量 二、使用变量 2.1跟踪变量 TensorFlow变量是能表示由程序操作的,共享的、持续时间长的状态...
  • 作为英语课程,读中文参考资料的确有助于理解,但是出于对以后更长久的学习优势考虑,笔记中我会尽量采用英文来表述,这样有助于熟悉专有名词以及常见语法结构,对于无中文翻译的资料阅读大有裨益。 一、Multiple ...
  • 一、如图翻译: 图1: 图2: 二、翻译: local Variable = 局部变量 argument = 论点 static Variable = 静态变量 global Variable =  全局变量 register =
  • 初次翻译,部分内容并非按字面翻译,是按本人理解进行了内容重组。如有错误望指正。 如下是变量定义和赋值的示例 var name = 'Bob'; 变量存储的是一个引用地址。如上的变量name指向了一个值为Bob的String对象。通过...
  • 前言 本文是橙子出于兴趣爱好对Java官方教程的尝试翻译,几乎每日更新,感兴趣的朋友可以关注一下橙子;翻译过程中尽可能多的对一些关键词保留了英文原文,如果你想看...Declaring Member Variables 声明成员变量 ...
  • tailwindcss CSS变量 翻译文件 语 文档链接 英语 文献资料 土耳其

空空如也

空空如也

1 2 3 4 5 ... 18
收藏数 350
精华内容 140
关键字:

variables翻译