w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
When should cache invalidation happen?
This depends on your specific requirements. The way I see it, you have 3 options: on change - when your entry gets edited, also delete the existing cache information (also make sure it gets re-created on request) periodically - have a cron job that runs once X time, and re-do the whole cache percent based (not sure how to call it) - when an entry is requested, do something like this: (basically below code means once in 1000 requests, the cache for the requested page is cleared) if (rand(1, 1000) == 666) { /** clear the cache for current requested page */ } /** handle request */ Depending on your traffic and amount of information you cache (probably other factors as well), any can be useful. #3 works great when you have a huge cache, while #2 is great with smaller caches that g

Categories : PHP

Django cache invalidation on transaction commit?
You should only delete from cache when the transaction has been committed. To ensure your transaction has been committed (for example, in case you're using django.middleware.transaction.TransactionMiddleware to commit upon every request), you can force a commit using commit_on_success: from django.db import transaction with transaction.commit_on_success(): # ... do db stuff ... cache.delete('key')

Categories : Django

Umbraco Editable Content Block
This is possible, I have created similar blocks in the past with XSLT, but of course it can be done with WebControls or MVC as well. First, on the DocumentTypes where you want to display the static content block, add a new field called StaticBlocks. The type could be a multilist or dropdown or so, whatever you prefer as long as you can choose at least one (ContentBlock) item from the content-tree. You need to create a new Document type, call it ContentBLock and add a RichText field to it. This is your static content block. Also create a template for this ContentBlock and make sure the template is rendered somewhere in your main layout. This template only contains a Macro (in my case it was an XSLT macro). The XSLT Macro reads the selected nodeID from the StaticBlocks field from your cu

Categories : Dotnet

rendering html content from umbraco
The information that you receive from your program is in the JSON format whereas with Firefox you are receiving it in the XML format. If you read the documentation on umbraco, which I have not used, there is most likely a parameter you can add to the GET URL to ask for either JSON or XML.

Categories : C#

Retrieve html content via examine umbraco
Examine removes all HTML elements, so all that is stored is content ( all tags are stripped for indexing ). You cannot do what you want to do with Examine. If you need the HTML from the node, you need to use the Umbraco API.

Categories : C#

Displaying a content managed image in a Umbraco 6 MVC website
Two things here: You don't need to cast the property value to an Int32, as TypeMedia() accepts a string or object id parameter. You can use the Url property of the IPublishedContent instead of GetPropertyValue("umbracoFile") So it becomes: <img src="@Umbraco.TypedMedia(Model.Content.GetPropertyValue("siteLogo")).Url"/> Which is much nicer isn't it? There are obviously many ways to shortne this, extension methods but one that a friend showed me recently was uMapper which allows you to create strongly typed objects corresponding to your document types, working much like AutoMapper. For a little leg work up front, your code can become much more understandable and concise.

Categories : C#

Umbraco: What can I do to fix my stream content with Multiple Node Tree Picker?
try this ..... <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:if test="count($currentPage/articlePicker/MultiNodePicker/nodeId) &gt; 0"> <xsl:for-each select="$currentPage/articlePicker/MultiNodePicker/nodeId"> <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(current())" /> <a href="{umbraco.library:NiceUrl($node)}"> <xsl:value-of select="$node/@nodeName" /> </a> </xsl:for-each> </xsl:if> </xsl:template> </xsl:stylesheet>

Categories : Dotnet

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

Colorbox code working outside of Umbraco, but not within
This looks like a problem with how you have implemented your script in Umbraco. Just looking through Chrome's browser inspector, I can see that your script is failing to find the colorbox objects which means that something is prevent the library from being available. This is usually because a dependent javascript library has failed. Looking at your source code, you are loading all your jQuery libraries at the bottom of your page. This is good practice, but you have placed your a second jQuery file reference, your colorbox file references and the custom colorbox code in the head of the page. There are several things you will need to do: Remove the jQuery reference from the head of the page; Move the colorbox file references to the bottom of the page, after all the other javascript file

Categories : Javascript

Umbraco MediaService / Umbraco MediaItem not saving
To Save media, I found this method with MediaService. However, I think it's possible another method more refined [HttpPost] public JsonResult Upload(HttpPostedFileBase file) { IMedia mimage; // Create the media item mimage = _mediaService.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image); mimage.SetValue(Constants.Conventions.Media.File, file); _mediaService.Save(mimage); return Json(new { success = true}); }

Categories : C#

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

Umbraco: Unable to get RelatedLinks property value in code-behind
What data type is your related links set to, assuming its a content picker where you are getting the id of the related page you could first create a node form your current page's id then try and get the value from that node e.g. var current = Node.GetCurrent(); var currentPage = Model.NodeById(current.Id); var relatedLinks = currentPage.RelatedLinks; or var relatedLinks = GetProperty("RelatedLinks").Value; when you debug you should be able to see all the properties of currentpage and check your alias as well to make sure its right (generally aliases dont start with a capital by default).

Categories : C#

Umbraco Rest Extension Not working after moving code from 4.7.1 into 4.11.10
Most probably your code is throwing an exception and this gets converted to a 500 error that masks it. So the problem could be anything. I had the same issue and the best thing I did was wrap all my code inside a try/catch and return the exception as a string. Remember that in order to get all the info from the exception you need to compile in Debug mode and copy the .pdb file along with your .dll. ... [RestExtensionMethodAttribute] public static string GetCountries() { try { return Core.RazorRenderer.RenderScriptFile("LandingPage/GetCountries", 0, GetLandingParameters(false)); } catch (Exception e) { return e.ToString(); } } ... Hope this helps you find the problem ! It worked for me.

Categories : C#

Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
If you are trying to host the blogengine site within a virtual directory of the Umbraco site, then you will have to amend the blogengine web.config to "remove" all the Umbraco-specific handlers and modules, as these will be inherited by the blogengine application, causing this exception because the application can't find the relevant DLLs in its bin folder. I recently had a similar problem and I have posted the web.config I used in the virtual directory below. Mine was a very simple web application, so obviously this will not work by itself in your blogengine app. You will need to add the relevant parts into your web.config file. Also, this was for a v6 Umbraco install in IIS7.5, so you may have to experiment a little. <?xml version="1.0"?> <configuration> <configSecti

Categories : Iis

creating a cache of byte arrays
If you effectively have many identical arrays, use an HashSet<ByteBuffer> as a cache. You can get the ByteBuffer array with method array() and the ByteBuffer class has hashCode and equals methods. Of course it is better if your arrays are immutable. EDIT2 The comment from @Will is exact, to be able to get back the array, use a WeakHashMap<ByteBuffer,WeakReference<ByteBuffer>> and do something like that : public byte[] internalize(byte[] bytes) { ByteBuffer wrapped = ByteBuffer.wrap(bytes); if(cache.containsKey(wrapped)) { wrapped = cache.get(wrapped).get(); } else { cache.put(wrapped, new WeakReference<ByteBuffer>(wrapped); } return wrapped.array(); }

Categories : Java

Creating dm-cache using dmsetup Kernel 3.9.6
The multibyte or wide character error message is troubling to me and I don't have any direct advice to working around that. I assume /dev/sdd1 and /dev/sdb1 are your metadata and data storage block devices? Do they contain any data? Have you tried zeroing out the metadata volume (dd if=/dev/zero of=/dev/sdd1)? I had issues with when setting up dm-cache a while back. In a nutshell I do the following (on Ubuntu 13.04 + Linux 3.10 release): dmsetup create ssd-metadata --table '0 19370 linear /dev/disk/by-id/scsi-SATA_OCZ-AGILITY2_f2d200034-part6 0' dmsetup create ssd-blocks --table '0 189008982 linear /dev/disk/by-id/scsi-SATA_OCZ-AGILITY2_f2d200034-part6 19370' dmsetup create home-cached --table '0 1048576000 cache /dev/mapper/ssd-metadata /dev/mapper/ssd-blocks /dev/vg0/spindle 512 1

Categories : Linux

Creating a cache layer for images
First of all as suggested by everyone storing images in DB is not a good idea... I think here by "Caching Layer" you mean not to fire a query to database if image is already present in filesystem.. if thats the case ... Keep all the final images which you have created from using script in a directory. Then use a rewrite rule which serves the image if present, otherwise pass off the creation to PHP. More explanation.. http://www.sitepoint.com/forums/showthread.php?719010-PHP-image-caching-in-server

Categories : PHP

Choosing content of cache in codeigniter
After Searching a lot for this problem i found this Simple Cache This really worked like a charm, if anyone who got the same problem may use it :)

Categories : PHP

Magento cache adds content twice
In your layout, you have two footer blocks, which use the same page/html_footer type. Or, this block type is not intended to be used more than one time on the same page, the first content it will display will be cached and returned on the later calls (see Mage_Page_Block_Html_Footer::getCacheKeyInfo()). So, for one of your footer blocks, you should use another block type (this should be footer_block, as it's the one not existing in base Magento). On a side note, your footer_block block is defined two times, once in page.xml and once in catalog.xml, and both of your footer blocks contain a child named bottom.container, so you could try to remove it from the definition of footer_block.

Categories : PHP

how to prefetch / cache iframe content?
Loading the iframe content makes the browser cache the page in it, so that if you load it a second time later, the browser will simply fetch it from cache, unless your server is set up to always load the content afresh. I suspect that if you're seeing it reload the iframe's page each time you revisit it, you either forgot to indicate how long the page should be cached for, or your server isn't set up to say "this page has not been modified since ..." so the browser doesn't try to reload the page, or the page is served with a header that indicates it cannot be cached. (If you want to preload the content for the first run, that's the same thing as loading it in the iframe, with the iframe hidden, and then showing it when the iframe content is ready.)

Categories : Javascript

Convert drupal 7 content type into code automatically. Content type generator code?
maybe this can help you. add hook_install(): please check: http://yaremchuk.ru/blog/how-create-content-type-drupal-7-programmatically

Categories : PHP

Creating a cache memory benchmark in VHDL
For getting random numbers, use the OSVVM - Open source, VHDL verification methodology library. To get your "interesting patterns", you could make use of the cache access data presented in Hennesey and Patterson's classic Computer Architecture to create realistic probabilities of a variety of small and large block sizes and separations.

Categories : Misc

Cache content loaded via AJAX in Fancybox
You could try $(document).ready(function() { $(".fancybox-effects").fancybox({ type : 'ajax', ajax : { cache: true }, wrapCSS : 'fancybox-custom' }); });

Categories : Ajax

What is iterator invalidation?
Iterators are glorified pointers. Iterator invalidation is a lot like pointer invalidation; it means it suddenly points to junk data. Because it's very natural but wrong to do things like this: for(iterator it = map.begin(); it != map.end(); ++it) { map.erase(it->first); // whoops, now map has been restructured and iterator // still thinks itself is healthy } Because that error right there? No compiler error, no warning, you lose. You just have to be trained well enough to watch for them and prevent them. Very insidious bugs if you don't know what you're doing. One of the design philosophies of C++ is speed over safety. The runtime check that would lead iterator invalidation to an exception instead of unspecified behavior is too expensive, in the view of C++ language d

Categories : C++

Android: Out of memory after creating and skewing Bitmap from Drawing Cache
I see at least 4 Bitmaps in de code snippet you posted. Make sure to read about proper bitmap recycling at this android developer training link or on this stackoverflow question. Recycle When adding recycle() calls make sure not to display a recycled bitmap or you'll get another error. Before assigning new bitmap information perform a recycle (if not null) and onDestroy of the view (or onPause if you're careful enough to recreate the bitmap onResume) A quick example: // you see how I moved this up to class scope instead? private Bitmap mScaledBitmap = null; void someMethod(){ // some code here // ... if(mScaledBitmap != null) mScaledBitmap.recycle(); mScaledBitmap = Bitmap.createScaledBitmap(mOfferText, 560, 720, false); // more code here // ... } publ

Categories : Android

how to clear cache of response header if the content(image) changed in asp.net
You don't. Once it's cached, it's cached. And that's exactly why I don't like caching. What you can do is add a parameter to the url, like http://www.whatever.com/images/myfile.jpg?no_cache=lastWriteTimeUTC

Categories : Javascript

Why does the objects reset after invalidation of an NSTimer?
If you're using auto layout, when the constraints are re-applied (which can be triggered by innocuous events, such as setting the text property of a label), everything will be placed back to where they were defined by the constraints embedded in the storyboard (assuming you were attempting to move the UIImageView objects programmatically simply by changing their frame or center properties rather than by changing the constraints). You can solve this in one of two ways. Move your UIImageView objects by changing the constant property for the constraint and then calling layoutIfNeeded method of the parent view, rather than changing the frame or center properties of the UIImageView itself. This can be simplified if, in Interface Builder, you create IBOutlet references for the constraints the

Categories : IOS

NSTimer firing despite invalidation and setting it to nil
I see 2 possible reasons of your problem. userInfo The user info for the timer. The object you specify is retained by the timer and released when the timer is invalidated. This parameter may be nil. You must send invalidate message from the thread on which the timer was installed. If you send this message from another thread, the input source associated with the timer may not be removed from its run loop, which could prevent the thread from exiting properly.

Categories : IOS

Polling Facebook regularly for oauth invalidation
I would actually prefer using the method you suggested first. You don't need to poll the API to verify the integrity of a token -- If you try to execute an API call with an expired token,Facebook will return an appropriate error message. Just add a fail-safe to detect this to any calls you're making.

Categories : Facebook

Saving Model Causes Failed Invalidation in has_many / belongs_to Relationship
To get around this issue, use inverse_of on both end of the association. class Customer < ActiveRecord::Base has_many :orders, inverse_of: :customer end class Order < ActiveRecord::Base belongs_to :customer, inverse_of: :orders validates :customer, presence: true end Then you should be able to do the following >> customer = Customer.new >> customer.orders << Order.new >> customer.save! # should create both customer and order

Categories : Ruby On Rails

How can i add cache control code to htaccess?
You can use something like this: # Cache Files <filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=604800, public" </filesMatch> This caches any file ending with ico|pdf|flv|jpg..... for 604800 seconds, which is one week, you can change that number to cache for however long you feel you need.

Categories : PHP

ASP.NET cache memory saving code
I think you mean "cache", not "catch"? I also think you want one place that runs on every request, instead of having to put code in every controller. In that case, you should look at adding to your Global.asax an event for Application_BeginRequest.

Categories : C#

clear cache using java code
You solved the first issue correctly, by adding its dependency commons-logging. The second one is, as stated, a warning and not an error (but nevertheless, I'd consider it a very serious warning, as the used defaults are quite probably not good for your application). It means that you forgot to add ehcache.xml, ehcache's configuration file, to the classpath. Add that file and the message will go away. Also note that the ehcache version you seem to be using (1.2.3) is very old, it was released in 2006. The current version is 2.7, and it can be downloaded here. Instructions for Maven based projects are also on that page.

Categories : Java

JVMSHRC559E Failed to create a directory "%s" for the shared class cache while creating server for Websphere liberty profile
The problem (as bkail is correct in pointing out), is that the server directory can't be created due to permissions. Given that you have Liberty installed in the Program Files directory, I would recommend setting the WLP_USER_DIR to move configuration files and servers into a directory you can write to, like C:Users\Liberty. Create a server.env file in the C:Program FilesIBMWebSphereLibertyetc directory, and add the following: WLP_USER_DIR=C:Users\Liberty (or whatever you choose). When you run subsequent create/start/stop/etc. operations, it will look for servers and configuration data in that directory instead, which should eliminate the requirement for administrative permissions in order to work with liberty servers.

Categories : Misc

Deploying code first code migrations based web app to server, but it's not creating the database
Well, one problem you have: you're defining both Integrated Security=True (i.e. Windows authentication) as well as User ID=...;Password=.... (i.e. SQL Server authentication) in your connection string. Choose one or the other - but not both at the same time! If you do have that user myUser specified as a login in your SQL Server, right now, it will not be used, because the Integrated Security=True setting will prevail ... So change your connection string to: <add name="Context" connectionString="Data Source=ServerDbInstance;Initial Catalog=blahblah;User ID=myUser;Password=myPassword" providerName="System.Data.SqlClient" /> and see if now, you're myUser user will be used.

Categories : Sql Server

why is the java code cache size growing?
I suspect that it is jconsole itself that is causing the problem. Or more precisely, the jmxremote stuff that allows jconsole to see what is going on inside your JVM. My advice: Don't worry about it. It looks like it has almost reached a steady state. If that's not good enough, then leave jconsole running for a very long time and observe if the memory usage growth stops completely. If that's not good enough, then you could try to profile it ... though tracking down small storage leaks in the jmxremote code (with or without source code) could be challenging.

Categories : Java

clear jboss cache using java code
You have three bugs in your code. First, you don't need to query getCacheNames(); you're already passing in the name of the cache you're wanting to clear, and you're just throwing away the results in st. Next, there's no such method as CacheManager#getCache(String); it's getCache(String, boolean) throws Exception, and you need to be passing s, false and handling the (far too broad Exception). Finally, you never check whether the cache actually exists; if someone passes in a name representing a nonexistent cache, cache will be null, and you'll get an NPE when you try to flush() it.

Categories : Java

Are events more cache-friendly code than virtual/overriden methods in C#?
I want to know if firing and handling events could be more cache-friendly than overriding methods when working with classes in C# In general, no. Events are going to require calling out to a separate class instance, which is going to be in a separate memory location. This is going to have the same (or likely even worse) cache issues than virtual method calls. or there is any better strategy than both approaches? Unfortunately, idiomatic C# tends to be non-cache friendly. In order to write cache friendly C# code, you typically want to use struct over class, avoid virtual methods, avoid events, avoid delegates (at least ones with closures), etc. Rico Mariani had a nice blog post on Value based programming which discusses many of these issues in detail.

Categories : C#

number of cache hits/miss vs page faults - C++ code - UBUNTU
The most comprehensive profiling tool for linux is oprofile, which can profile single applications or your entire system, and can give you detailed information about cache misses (and where they are occurring) on processors that support performance counters for events like cache misses (pretty much all x86 processors made for the past 20 years support such counters) Page faults have nothing to do with cache misses, though they are also a potential source of performance problems.

Categories : C++



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