MySQL的查询缓存其实就是保存查询返回的完整结果.如果执相同 SQL 语句的时候,并且查询缓存是打开的,则 MySQL 会直接返回结果(在这一过程中 MySQL 还检查了一次用户权限),跳过解析,优化和执行过程.这里判断 SQL 语句是否相同是通过一个对大小写铭感的哈希查找实现的,这就意味着下面两条查询缓存是不同的:
1 2
SELECT id FROM t_user; select id from t_user;
简单的了解了一下查询缓存,所以
如何查看查询缓存的相关参数
使用下述命令:
1
SHOW VARIABLES LIKE '%query_cache%';
结果:
其中:
have_query_cache 查询缓存是否可用
query_cache_limit 可缓存具体结果的最大值
query_cache_size 查询缓存的大小
query_cache_type 阻止或者支持查询缓存
如何查看 SQL 查询在缓存中的命中的累积次数
使用下述命令:
1
SHOW STATUS LIKE 'Qcache_hits';
关于查询缓存
当查询语句中有一些不确定的数据时,则不会被缓存。
如果表发生变化,那么跟这个表相关的所有的缓存数据都将失效,这里的变化包括:INSERT, UPDATE , DELETE, TRUNCATE, ALTER TABLE 等,由此可见对于频繁更新的表,显然是不适合使用查询缓存的.
@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance. @staticmethod means: when this method is called, we don’t pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can’t access the instance of that class (this is useful when your method does not use the instance).
PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/ASRM/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /v ar/www/html/ASRM/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
执行成功后会返回如下信息:
1 2
lt94@ubuntu:/var/www/html/ASRM$ php artisan key:generate Application key [base64:yUNJlAGBxWrxRutexftuJzVmzvllHXANxerkojqLscg=] set successfully.
The heart of a generator function is the yield keyword. In its simplest form, a yield statement looks much like a return statement, except that instead of stopping execution of the function and returning, yield instead provides a value to the code looping over the generator and pauses execution of the generator function.
Because generators compute their yielded values only on demand, they are useful for representing sequences that would be expensive or impossible to compute at once. These include e.g. infinite sequences and live data streams.
var displayFeature = function (pixel) { var features = []; map.forEachFeatureAtPixel(pixel, function (feature, layer) { if (layer.getVisible()) { // 当图层被隐藏之后,光标下该图层忽略 features.push(feature); } });
var len = features.length; if (len > 1) { for (var i = 0; i < len; i++) { var text = features[i].getProperties().text; var type = features[i].getGeometry().getType(); features[i].setStyle(getSelectedPropertyStyle(type, text)); } } else { var featureArr = map.getLayers().getArray(); var featureArr_len = featureArr.length; for (var j = 0; j < featureArr_len; j++) { if (typeof featureArr[j].setStyle !== 'undefined') { var source = featureArr[j].getSource(); features_by_source = source.getFeatures();
var feature_len = features_by_source.length;
for (var m = 0; m < feature_len; m++) { if (typeof features_by_source[m].getProperties().text === 'undefined') { text = 'none'; } else { var text = features_by_source[m].getProperties().text } var type = features_by_source[m].getGeometry().getType(); features_by_source[m].setStyle(getUnselectedPropertyStyle(type, text)); } } } } };
var getUnselectedPropertyStyle = function (type, text) { var style = null; if (type == 'Circle') { style = new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(57,172,106,0.9)', opacity: '0.05' }), text: new ol.style.Text({ font: '14px sans-serif', text: text, textAlign: 'center', rotateWithView: true, fill: new ol.style.Fill({ color: '#FFFFFF' }), stroke: new ol.style.Stroke({ color: '#FFFFFF', width: 1 }) }) // radius:100 }) } if (type == 'MultiPolygon' || type == 'Polygon') { style = new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'rgba(255, 255, 0, 0)', width: 2 }), fill: new ol.style.Fill({ color: 'rgba(255, 255, 0, 0)' }) }) } return style; };
var getSelectedPropertyStyle = function (type, text) { var style = null; if (type == 'Circle') { style = new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(228,57,60,0.9)', opacity: '0.05' }), text: new ol.style.Text({ font: '14px sans-serif', text: text, textAlign: 'center', // rotateWithView:true, fill: new ol.style.Fill({ color: '#FFFFFF' }), stroke: new ol.style.Stroke({ color: '#FFFFFF', width: 1 }) }) }) } if (type == 'MultiPolygon' || type == 'Polygon') { style = new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'green', width: 2 }), fill: new ol.style.Fill({ color: 'rgba(57,172,106,0.1)' }) }) } return style; };