w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Is querying a MySQL database dozens of times in order to allow effective caching better than a few large queries with less caching?
The correct answer is: It depends. Caching is a way of optimizing a recognized use pattern by shortcutting producing repeatedly expensive data with re-using the data from a previous run. So the first question you should answer is: It there an observed repeated use pattern that has a noticable "expensive" step of producing data? If not: Don't use caching that you still do not need, wait until you can observe something. The second question you should be able to answer is: Can you measure how long it takes with and without cache, and is the difference noticable? And the third important question to answer is: How can you clean the cache from outdated information if the original data gets changed, and you want that new data to be displayed instantly? So in your case you are asking if using

Categories : PHP

Multiple instances use a co-located caching but fail to access, good named caching implementation required
First I'd move your cache and cacheFactory instantiation out of your getPrices method. Also, evaluate your need for the lock - this may be causing timeouts. Another VERY important observation - you are using a constant cache key and saving/retrieving data for every productId with the same cache key. You should be using a cache key like: var cacheKey = string.format("priceDatabyProductId-{0}", productId);. You need to set some breakpoints and examine exactly what you are caching and retrieving from the cache. The code as written will save the first productId to the cache and then keep returning that data regardless of the productId. Here is a full working example we use in production using the "default" named cache in dedicated cache roles: public static class MyCache { private

Categories : Asp Net

Caching dynamic pages / excluding parts from caching
Ok, the solution was fragment caching. First you have to set your secret phrase by setting define('W3TC_DYNAMIC_SECURITY', 'my_string'); in wp-config.php and then you can use PHP code like this <!-- mfunc echo "Hello World<br/>"; --><!-- /mfunc --> which outputs this dynamic code <?php echo "Hello World<br/>"; ?>

Categories : PHP

Azure Caching - Failure after upgrading to SDK 2.1 and caching 2.1
Not really an answer but some comments which might help you diagnose the problem: Visual Studio 2012/Update 3 - Please ensure that you have latest updates applied to VS. We had gone through similar problems and this was one of the things that helped us. Collect lots of cache diagnostics data - In your cache configuration section, change the Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel value to 4 in your cache worker role's configuration section. After you do that, add the following lines of code in your cache worker role's OnStart() method: DiagnosticMonitorConfiguration dmConfig = DiagnosticMonitor.GetDefaultInitialConfiguration(); // Configure the collection of cache diagnostic data. CacheDiagnostics.ConfigureDiagnostics(dmConfig); DiagnosticMonitor.Start("Microsoft.Window

Categories : Caching

What is distributed caching in terms of caching persistent data for multiple applications/ multiple instances of an application
My best attempt for answers: I would say both. A distributed cache means that the logical idea of a cache is spread across multiple distinct machines. For example, you might have 5 nodes in your cache, and each node is on it's on machine/VM. Usually once you need a distributed cache, your application is also distributed. Small website = one server, maybe one cache node. Big website = many web servers, distributed cache. Most distributed caches distribute the cache entries evenly amongst nodes. If you write an entry to one node, it will get replicated to all other nodes. The idea is that each cache node can be taken out of the "cluster" and you don't lose any data. The idea of having one cache entry on one machine is called sharding. It means you look at the cache key and then decide w

Categories : Caching

Django per-view caching not caching
I think there are some mistakes in your code :) UpdateCacheMiddleware must be the first middleware and FetchFromCacheMiddleware must be the last (https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache) Dont know if 'django_pylibmc' is a shortcut in your cachebackend but in my settings it is "django.core.cache.backends.memcached.PyLibMCCache" Maybe that helps.

Categories : Django

How can i use MapBox on Android
I think Nutiteq looks pretty promising. Their API has a lot of features. Also, their demo projects are inline commented. You can check out this project. Especially, MBTilesMapActivity might be something that you're looking for. The class shows how to work with mbtiles: // 1. Get the MapView from the Layout xml mapView = (MapView) findViewById(R.id.mapView); // 2. create and set MapView components Components components = new Components(); mapView.setComponents(components); // 3. Define map layer for basemap MBTilesMapLayer dbLayer = new MBTilesMapLayer(new EPSG3857(), 0, 19, file.hashCode(), file, this); mapView.getLayers().setBaseLayer(dbLayer); ... // 4. Start the map - mandatory mapView.startMapping(); // 5. zoom buttons using Android widgets - optional // get the zoomcontrols

Categories : Android

mapbox points on a rails app
I am assuming that you are using the Mapbox.js API... If you are... You will need to put some javascript on to your web page which will list the points. You can then add the long/lats by calling a method in your code behind. Like so.... <link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.css' rel='stylesheet' /> <script src='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.js'></script> <style> #map { width: 100%; height: 600px; } </style> <div id='map' /> <script type='text/javascript'> var map = L.mapbox.map('map', '[yourmapname]') L.mapbox.markerLayer({ type: 'Feature', geometry: { type: 'MultiPoint', coordinates: [ <%=getPins()%> ] }, properties: {

Categories : Javascript

How can I find the lat/lon of a marker in MapBox?
You might want to use the dragend event as it fires after a marker has been dragged. If you peer into what e.target returns there is a _latlng object that gives you the details you need: marker.on('dragend', function(e){ console.log(e.target._latlng); }); An underscore used in a method name implies that its private so there may be a more appropriate way to access this but for now should suit your needs.

Categories : Javascript

Clustering markers on mapbox / leaflet
var geojson = dataFromMapbox; var lat; var lng; for(var i= 0;i<geojson.features.length;i++) { lat = geojson.features[i].geometry.coordinates[0]; lng = geojson.features[i].geometry.coordinates[1]; //create a marker with those values, pass it to a MarkerCluster object }

Categories : Javascript

Set range of markers in MapBox or Route-me
You want this API to constrain the map: http://www.mapbox.com/mapbox-ios-sdk/api/#//api/name/setConstraintsSouthWest:northEast:

Categories : IOS

MapBox scroll page on touch
Remove the rest of the listeners as in this example - the one you probably still have is dragging.

Categories : Javascript

Setting a default popup from the URL in a modestmaps/mapbox wax map
You can do something like this $(document.elementFromPoint(x, y)).click(); https://developer.mozilla.org/En/DOM:document.elementFromPoint

Categories : Javascript

Trouble using Leafletjs MarkerClusterGroup and filters with Mapbox
I found the solution with some help. This is the method I used : <script type='text/javascript'> // I suppose that the json is saved in the var dataJSON L.MarkerClusterGroup.include({ fromGeoJSON: function (geojson) { this._geojson = geojson; this.filter(); }, filter: function (f) { f = f || function (m) { return true; } var markers = Array(); for (var i = 0; i < this._geojson.features.length; i++) { var a = this._geojson.features[i]; if (!f(a)) { continue; } var title = a.properties['title']; var description = a.properties['description'] var marker = L.marker(new L.LatLng(a.geometry.coordinates[1], a.geometry.coordinates[0]), { icon: L.mapbox.marker.

Categories : Javascript

How are markers added to a map (Google JS api, Leaflet, or Mapbox)?
how are markers actually added to a map In the simplest implementation, markers are represented as GeoJSON or similar, and requested from the server, and then 'projected' into screen coordinates from lat/lon; see node-sphericalmercator for one example of that logic. For the 'performant' case, like TileMill or Google's pre-rendering mode, markers are baked into raster tiles, PNG files, that show them and their locations, and you do magic like UTFGrid to do interaction. Note that both of these are compromises: you can get speed, flexibility, and simplicity, but it's very hard to get all at the same time.

Categories : Google Maps

Adding dynamic markers on to mapbox map file.
I don't know GeoJSON, but this is how you handle it using the Google Maps v3 API: For one marker: lng = (4.502384184313996, 4.461185453845246); lat = (51.011527400014664, 51.02974935275779); cur_loc = new google.maps.LatLng(lat, lng); var marker = new google.maps.Marker({ position: cur_loc, //To be defined with LatLng variable type draggable: false, animation: google.maps.Animation.DROP, icon: image }); // To add the marker to the map, call setMap(); marker.setMap(map); For multiple markers retrieved from MySQL (Ajax): google.maps.event.addListener(map, 'idle', function () { var bounds = map.getBounds(); var ne_lat = bounds.getNorthEast().lat();

Categories : Javascript

Creating a GeoJson in php from MySql to use with MapBox javascript API
Have a look at this: https://github.com/bmcbride/PHP-Database-GeoJSON You are returning array instead of Json data. This is what it should look like <?php /* * Title: MySQL Points to GeoJSON * Notes: Query a MySQL table or view of points with x and y columns and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc. * Author: Bryan R. McBride, GISP * Contact: bryanmcbride.com * GitHub: https://github.com/bmcbride/PHP-Database-GeoJSON */ # Connect to MySQL database $conn = new PDO('pgsql:host=localhost;dbname=mypostgisdb','myusername','mypassword'); # Build SQL SELECT statement including x and y columns $sql = 'SELECT *, x AS x, y AS y FROM mytable'; /* * If bbox variable is set, only return records that are within the bounding box * bbox sh

Categories : PHP

Import large CSV file into TileMill for use in MapBox
I have the same problem. I had to import a 22MB csv file into tilemill and got the same error. Although I don't have a working answer for you, but I would think either: Convert csv to SQLite export files http://www.mapbox.com/tilemill/docs/tutorials/sqlite-work/ Configure the buffer for tilemill (however I doubt this would be the best because my tilemill cant take 5 GB of memory when doing points/markers rendering, increasing the buffer would make things worse) I will keep experimenting with the ideas, and update this thread as soon as I found something. Also, I am looking forward to the tillmill pros out here for the best working answer~! Best

Categories : Misc

Mapbox show Exception and terminate when using mbtiles in ios
The reason for the crash is clear from your question itself. reason : [NSURL initFileURLWithPath:]: nil string parameter. You are initializing NSURL without passing a nil parameter. Search for initFileURLWithPath and check wether the parameter is nil or not [NSURL initFileURLWithPath:] // Pass a valid path here

Categories : IOS

Mapbox marker property update: Why doesn't this work?
This is more of a basic Javascript question: objects hold references to variables. If you change these references in the object then they're updated in place. If you pull out the variables themselves and change them, they aren't. Example: http://mistakes.io/#6220549

Categories : Javascript

Playing with loaded geojson makers on mapbox with javascript
I think you want this: ... var reg20 = /20d*/g; console.log(stryear.match(reg20)); return f.stryear.match(reg20)[0] == '2012'; match() returns an array of matches, so access the first match by adding [0]. Also use == to compare values, not === which compares objects.

Categories : Javascript

Switch from Terrain layer to Satellite layer using Mapbox
With MapBox there is no concept of "modes", just different maps each with their own Map ID. So create a map at http://tiles.mapbox.com/newmap based on terrain, then another based on satellite imagery. Switch between them with the second argument to L.mapbox.map (see http://www.mapbox.com/mapbox.js/api/v1.0.4/#L.mapbox.map) using their respective IDs.

Categories : Javascript

Leaflet.js & Mapbox.js - Uncaught TypeError: Object [object Object] has no method 'on'
try: markers = L.layerGroup().addTo(map); notice the lower camel case on layerGroup You can't call .addTo on an object that isn't instantiated yet, you're alternative would be: markers = new L.LayerGroup(); markers.addTo(map); http://leafletjs.com/reference.html#layergroup

Categories : Javascript

JVM and OS DNS Caching
I think I've run into this problem, or a very similar one. What I did then was to implement my own DNS provider for the JVM, see how to change the java dns service provider for details. You can use the dnsjava mentioned there or roll your own.

Categories : Java

PHP caching - out of the box
As far a I know, there is no default caching mechanism in PHP similar to .NET's application object. The only thing that comes close is storing things in the $_SESSION object, but that would mean caching per user and not global caching.

Categories : PHP

Using an appropriate key for caching
No harm in using employeeId as the key but its better to prefix this with something like Employee so that another Object in the cache with same id doesn't overwrite your employee cache entry. So something like this: // employee is an instance of Employee cache.put("Employee::" + employee.getId(), employee); EDIT: If you dedicated buckets for each object type // employee is an instance of Employee cache.put(employee.getId(), employee);

Categories : Caching

The best way to caching json
Based on your requirement I would recommend SQLite data base. Since shared preference is suitable for configuration storage - often small data/strings. File cache is hard to manage, so I recommend SQLite - easy to manage and ability to store mass data. Considering the performance, if the number of index is not that huge, SQLite database should have the acceptable performance. E.g. only several ms slower than a file cache. You might be able to combine these two approaches together. Use random access file with index-offset stored in SQLite.

Categories : Android

No caching in HTML5
I think if you leave out the manifest attribute, it defaults to no cache. I know that on firefox, you can use add-on tools like Firebug or HttpFox to check if the page is cached. Not sure about other browsers, but most likely it's under "Network" tab of developer tools.

Categories : HTML

Dictionary and Caching
In this case I don't think you are going to get a unique key But you can do better This suffers from if you switch left and right you get the same key. Int32 key = left.GetHashCode() ^ right.GetHashCode() ^ weight.GetHashCode(); 15 ^ 17 ^ 20 == 17 ^ 15 ^ 20 This will decrease key collisions Int32 key = 17*left.GetHashCode() ^ 23*right.GetHashCode() ^ weight.GetHashCode(); Better yet can use an UInt64 key UInt64 key = (((UInt64)left.GetHashCode() << 32) | (UInt64)right.GetHashCode()) ^ ((UInt64)weight.GetHashCode() << 30); And look at how you average. All of those colors are being cast to Double in the calculation and that has overhead. How exact to that have to be? If weight and complement were Int32 there would be some rounding error but it would be faster. Int3

Categories : C#

Caching in Codeigniter
please put htaccess file in the folder and write : Header set Cache-Control "max-age=29030400, public" now please put this htaccess file in folder which file you want to make cache.

Categories : Codeigniter

ASP.NET MVC AntiForgeryToken and Caching
This is the expected behavior. Caching nicely caches the answer, including the value of the AntiForgeryToken. Disable caching on forms, and in particular on pages that use AntiForgeryToken. If you think about this further, if you're in a data-entry app, do you want to cache your data-entry forms? Probably not. However you do want to cache heavy reports -- even if it's just micro-caching -- a second or two.

Categories : Caching

Hibernate caching by example?
For #1, couple of thoughts: Let underlying cache implementation (i.e. ehcache) do the eviction for you by using concepts such as time (timeToLive, TimeToIdle) or capacity (MaxelementInMemory) evictions... If using hibernate 3.x, you can access the evit*() method directly from the sessionFactory object. Or, if using Hibernate 4.x, you can use the evict*() methods as part of the org.hibernate.Cache Interface (the methods out of the SesisonFactory are still there...but deprecated)(http://docs.jboss.org/hibernate/orm/4.2/javadocs/org/hibernate/Cache.html#evictEntity(java.lang.String,%20java.io.Serializable)...So for example, to evict all the entities from a cache region: sessionFactory.getCache().evictEntityRegion(entitClass); Finally, much more tied to the underlying Cache implementation (

Categories : Java

Caching big data
I would consider a NoSQL storage engine. I am thinking at Redis in particular. Redis is a in-memory, fast, key-value store with persistence, which should be a good fit for this kind of scenario. You can then defer most of the lock/consistency hassle to it. A problem with Redis is if you are really bound to a Windows env. There is an "unofficial" port of redis; the port is done by Microsoft itself.. but I admit that I would not be extremely confident in using it in production. As for a C# client/library, there is Booksleeve. This site (SO) uses it :) so I bet it is pretty stable! Of course you will need to tailor Redis to your needs. Redis does offer persistence, and the persistence is configurable (see http://redis.io/topics/persistence). Also, it offers expiration of objects (http://re

Categories : C#

Caching redirects in asp.net
Programatically you can try something like this: Response.Cache.SetExpires(DateTime.Now.AddDays(1)); Response.Cache.SetCacheability(HttpCacheability.Private); Response.Cache.SetValidUntilExpires(true); Response.AddHeader("Vary", "User-Agent, Accept-Encoding"); Response.Redirect("http://www.avnetwork.com/index");

Categories : Asp Net

Codeigniter caching?
The point of CI caching is to reduce the number of database queries, any time-consuming PHP calculations, etc... Basically, it will render a plain HTML page from your controller (and all the views it calls, of course). So, it won't really speed up your header and footer, unless you pull the data for them from the database or anythings that dynamic and heavy... but any modern browser will cache that for you unless you specifically disallow caching. So, the bottom line, CI caching allows caching of the full pages only, no separate parts. Of course, there are alternative ways to achieve what you wanted, for example you can make the header and the footer separate controllers, put caching in them, and call them by AJAX... but I'm not sure it's worth it.

Categories : PHP

Caching framework for .NET
Memorycache simply suits your case by just adding into your repositories But remember: The MemoryCache class is similar to the ASP.NET Cache class. The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class. The main differences between the Cache and MemoryCache classes are that the MemoryCache class has been changed to make it usable by .NET Framework applications that are not ASP.NET applications. For example, the MemoryCache class has no dependencies on the System.Web assembly. Another difference is that you can create multiple instances of the MemoryCache class for use in the same application and in the same AppDomain instance.

Categories : C#

Haskell Caching
This concept is called partial application . It works because in Haskell, all functions actually only have one parameter. A function a -> b -> c might look like a function that takes two parameters (one of typa a, and one of type b), but it's really a function a -> ( b -> c), i.e. a function with one paramater (of type a) that returns a function that takes a parameter (of type b). See http://www.haskell.org/haskellwiki/Partial_application (or just generally, give http://learnyouahaskell.com/ a go)

Categories : Haskell

How does caching work in JAX-RS?
Yes. When using a browser like firefox or chrome, you don't need to worry about HTTP cache because modern browsers will handle it. For example, it uses in-memory cache when using Firefox. When using Android, it depends on how you interact with the origin server. According to WebView, it's actually a browser object, but you need to handle HTTP cache on your own if using HTTPClient. It's not about HTTP caching but your server-side logic. the common answer is using database cache so that you don't need to hit database in every HTTP request. Actually JAX-RS just provides you ways to work with HTTP cache headers. you need to use CacheControl and/or EntityTag to do time based cache and conditional requests. for example, when using EntityTag, the builder will handle response status code 304 whic

Categories : Java

C# File Caching
Odds are, you're catching an exception in the else block and it's only returning the fileContents. Try putting a breakpoint in the exception block to see what is going on. You'll need to change it to: catch( Exception e ) in order to get this information. Also, you don't need this: File.Delete(filePath); The WriteAllText method will overwrite the file that is already there. Try removing that line and check your directory permissions. You may also want to change (File.GetLastWriteTime(filePath) > DateTime.Now.AddMinutes(-30))) to (DateTime.Now - File.GetLastWriteTime(filePath)).TotalMinutes > 30

Categories : C#

.htaccess and PHP caching
I'm not understanding what you describe as happenning since you deleted the file, and you've not said what was in the .htaccess which which caused the problem, nor what the resulting impact was. However....you don't need to do anything more than delete the .htaccess file - Apache does not cache it.

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.