I look that the signature of umbraco.content.AfterUpdateDocumentCache event uses umbraco.cms.businesslogic.web.Document object. Unfortunatelly it is deprecated in "Umbraco 7".
What is the new event?
I'm the same issue in umbraco.content.AfterClearDocumentCache event.
Thanks
It doesn't appear there's any analog for umbraco.content.AfterUpdateDocumentCache in the umbraco7 code.
It seems you may have to reconsider you implementation approach to the available events hanging off Umbraco.Core.Services.ContentService
Looking at the u7 implementation of ContentService.Publish, for example, this call the internal SaveAndPublishDo which shows that the PreviewXML and the ContentXML disc caches are called before firing the Saved and Published (via Umbraco.Core.Publishing.PublishingStrategy) events. I presume the old umbraco.content.AfterUpdateDocumentCache was a single event that happened after both of the aforemented events. In it's absence - i believe you may have to watch for the saved/published/deleted events separately.
I can see that there are a bunch of events that would cause the cache update and it'd be a pain to wire them up separately - but maybee a different approach specific to the granularity of the available events is an upgrade?!
It may also help to backtrack from Umbraco.Core.Cache.CacheRefresherBase where i see there are events like OnCacheUpdated. They exist end do fire - though i'm not sure if or where they are publicly exposed.
This is probably more appropriate as a comment (i need more pts) as it's not a 100% resolution to your question. Hopefully it may be helpful to nudge in the right direction?
http://issues.umbraco.org/issue/U4-3462
According to this thread, answered by members of the Umbraco team, the AfterUpdateDocumentCache should still be used and the deprecated parameters are safely ignorable
I decided to use AfterUpdateDocumentCache in Umbraco 7 but noticed two issues. First of these is double firing this event. Second problem is that I retrieve the same not modified content when rendering page just in this event.
Then I decided to use CacheRefresherBase and CacheUpdate event but still have the same problem. Probably due to additional cache refreshing propagation.
The only workaround I see is to use Thread.Sleep in the new Task and perform purging url a little bit later.
Related
I was attracted to Fyne (and hence Go) by a promise of thread safety. But now that I'm getting better at reading Go I'm seeing things that make be believe that the API as a whole is not thread safe and perhaps was never intended to be. So I'm trying to determine what "thread safe" means in Fyne.
I'm looking specifically at
func (l *Label) SetText(text string) {
l.Text = text
l.textProvider.SetText(text) // calls refresh
}
and noting that l.Text is also a string. Assignments in Go are not thread safe, so it seems obvious to me that if two threads fight over the text of a label and both call label.SetText at the same time, I can expect memory corruption.
"But you wouldn't do that", one might say. No, but I am worried about the case of someone editing the content of an Entry while an app thread decides it needs to replace all the Entry's text - this is entirely possible in my app because it supports simultaneous editing by multiple users over a network, so updates to all sorts of widgets come in asynchronously. (Note I don't care what happens if two people edit the same Entry at the same time; someone's changes will be lost and I don't care who's. But it must not result in memory corruption.) Note that one approach I could take would be to have the background thread create an entirely new Entry widget, which would then replace the one in the current Box. But is that thread safe?
It's not that I don't know how to serialize things with channels. But I was hoping that Fyne would eliminate the need for it (a blog post claims it does); and even using channels I can't convince myself that a user meddling with a widget in various ways while some background thread is altering it, hiding it, etc, isn't going to result in crashes. Maybe all that is serialized under the covers and is perfectly safe, but I don't want to find out the hard way that it isn't, because I'll have no way to fix it.
Fyne is clearly pretty new and seems to have tons of promise, but documentation seems light on details. Is more information available somewhere? Have people tried this successfully?
You have found some race conditions here. There are plans to improve, but the 1.2 release was required to get a new "BaseWidget" first - and that was only released a few weeks ago.
Setting fields directly is primarily for setup purposes and so not expected to be used in the way you illustrate. That said, we do want to support it. The base widget will soon introduce something akin to SetFieldsAndRefresh(func()) which will ensure the safety of the code passed and refresh the widget afterward.
There is indeed a race currently within Refresh(). The use of channels internally were designed to remove this - but there are some corners such as multiple goroutines calling it. This is the area that our new BaseWidget code can help with - as they can internally lock automatically. Using this approach will be thread safe with no changes to the developer in a future release.
The API so far has made it possible for developers to not worry about threading and work from any goroutines - we do need to work internally to make it safer - you are quite right. https://github.com/fyne-io/fyne/issues/506
Several months ago I met a flux and I found it's awesome, I love it, I use it.. almost in every new project and when I met a redux I love it even more, but couple of days ago Pete Hunt publish a tweet where he judge the people to use flux for everything. And I think it have a perfect sense, but on the other hand I don't get it.. He publish another tweet where explain cases for flux, also I read an article about use cases for flux. Long story short - "If your app doesn’t have complex data changes and caching, don’t use it. But if it does, I strongly recommend you try Flux." and it's totally make sense for me why I should use flux, but it not clear to me why I shouldn't if I don't have a complex data changes.
In the article Dan point, that when you faced those issues(that flux solve) in real project you can easier to understands the benefits of the flux, but exactly of this(cause I faced with these problems at work project) now I try to use flux in every project, because I don't wanna to deal with it anymore.
And crazy part, that now I often use it also for ui states, not just data changes. Let's pretend I can have a widget component, for example a clock. It can make some ui changes, like show/hide seconds, switch between digital/analog and it has a daytime type state(day/night) and can dispatch an event when it changed, but other component listen it and can react, for example change a background color. I can easily solve it just with local component state and container(smart component) state, but same as I can put all these logic into store(reducers) and components will be really dump and just react on the current state(props) and containers(smart) just listen the store and partitioned state between the components. And if even it looks ok, point that I can use it for every ui state - open/close sidebar, some specific component changes, etc.
Reasons why I can do it:
It looks predictable for me. I completely know that any changes happened in my app serve in one place.
It easy to debug. I can just log all the actions and if I will get some bug, I can easily found what happened and reproduce it.
I can easily expand my app without worrying, mb I should move something to the flux state, cause I already did it.
But also I agree that it's looks overwhelmed and I can solve it without flux, but I can't answer to me, why I shouldn't use flux in these cases. What is wrong with it? Please help me.
Well, my question is, which I should use when?
For example I use AJAX calls for all my form submissions - both user creations, advertisements creations, editing advertisements and so on.
Is there any golden rule about when to use event-tracking and when to add a page-view manually? :)
Is there any disadvantages in one of them regarding to e.g. goal tracking and so on? :)
Thansk in advance!
The important thing is that you can't have funnels with event based goals, so if you want to track at which point people drop out of a multi-step process you would need virtual pageviews.
Other than that there are only "best practices" which are somewhat open to interpretation - I use virtual pageviews when I update significant parts of the content, but your idea of what is significant might be different than mine. So you need to get everyone who uses your tracking implementation on board - they need to be aware what parts of the site are tracked in which way, especially if they try to compare your site with another - and you should have extensive, regularly updated documentation.
There is more than one way to do it, so it's important that your way is well documemted and reproducible.
In this MSO bug report, our very own waffles makes the following observation:
This bug also happens to be a heisenbug, when debugging it if your first breakpoint is too early, stepping through shows that everything is good.
(Ref: Wikipedia's entry on Heisenbugs)
How is it even possible for the location of a breakpoint make a difference in whether a bug appears?
(Yes, I know the Wikipedia article answers this, but I thought it'd be a good question for SO to have the answer to, and I bet SO can do better anyways.)
If there is any kind of asynchronous activity going on then this could affect heisenbugs. e.g. threads, I/O, interrupts, etc. Setting breakpoints in different locations would affect the relative timing of the main thread and the asynchronous events which could then potentially result in related bugs either showing up or disappearing.
A common source is timing, in particular with multiple threads.
Lets say you have a GUI app with some event handlers and a bug where a table selection is not handled correctly, perhaps because Swing sometimes start updating the table before your event is handled.
By pausing a thread at a breakpoint, you may change the order in which the table component receives events and thus you might see a different outcome with and without the breakpoint. It's a very common problem, and one of the things that can make debugging complex GUI apps with lots of events really painful.
I'm going back over some crufty code to tidy it up and I see I've been retaining NSTimers returned from scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: and storing them in a field - then releasing and nulling the field when it fires. In some cases I use the timer to send an invalidate message to it later - but in many cases not.
In more recent code I usually just schedule the timer and forget about it. I understand that the constructor method is autoreleasing and the timer is retained by the run loop while it is active - so I don't see any issue with this.
So, just to round out my understanding - is there any other reason I should be holding on to my timers, or is what I am doing now the accepted idiom?
This is all in the context of iPhone code, but I don't believe this is iPhone specific.
I just let the run loop handle the retention, myself - it's the run loop that owns the timer and not me. If you see what I mean.
I'm answering my own question.
I was mostly asking the question because I'd been browsing through the class reference docs and this issue was not really made clear. I've since read the Timer Programming Topics: Using Timers article in the ADC and it covers it pretty well - especially the section on memory management at the end.
According to that what I am doing now (just scheduling, unless I need to be able to call invalidate, or isValid etc) is the right way.