Find when an item was added to a cache - asp.net

So, I'm learning about caching...
I'm building a function to compress and cache JS files.
I'm trying to make it update any time I change a file though, to do this, I am trying to compare the lastWrite time of the JS files on my server and the time that the cache file was written.
So, adding the data to the cache looks like this:
HttpContext.Current.Cache.Insert("cachedJS", FileJS, Nothing, DateTime.Now.AddMinutes(1200), TimeSpan.Zero)
And I can retrieve this data easily enough, but, how do I determine the lastWriteTime of the CACHE key?

You can develop extension methhod InsertWithLog and use this method to insert item in your cache, and trace the time of insertion, but it's not possible to realize this work without customization.
Here all avaiable format of Insert :http://msdn.microsoft.com/en-us/library/system.web.caching.cache.insert%28v=vs.71%29.aspx

Related

Dynamic output issue when rowset is empty

I'm running a u-sql script similar to this:
#output =
SELECT Tag,
Json
FROM #table;
OUTPUT #output
TO #"/Dir/{Tag}/filename.txt"
USING Outputters.Text(quoting : false);
The problem is that #output is empty and the execution crashes. I already checked that if I don't use {tag} in the output path the script works well (it writes an empty file but that's the expectable).
Is there a way to avoid the crash and simply don't output anything?
Thank you
The form you are using is not yet publicly supported. Output to Files (U-SQL) documents the only supported version right now.
That said, depending on the runtime that you are using, and the flags that you have set in the script, you might be running the private preview feature of outputting to a set of files. In that case, I would expect that it would work properly.
Are you able to share a job link?

view nlog's output as a web page with asp.net

In an ASP.NET application, is there a way to get the nlog output to go in a buffer in memory?
I'd like to make a circular buffer that would display the log's content on a web page.
What about writing to the memory target?
Then you could read them as follow:
var target = LogManager.Configuration.FindTargetByName<MemoryTarget>("target1");
var logs = target.Logs;
You can specify custom targets with NLog: https://github.com/nlog/NLog/wiki/Targets
It does not look like one exists that does exactly what you need, but you can write your own!
https://github.com/NLog/NLog/wiki/Extending-NLog
Why don't you read tail n-lines from the actual log file and display it? Or send to a database and display the table? Seems that this will added more overhead and memory constants to the ASP.Net site.

Groovy - how to delay Groovlet modification recompile check

I am new to Groovy, and I am thinking about using Groovlets (not GRAILS) to replace some Servlets. If I change a Groovlet's script file, the Groovlet re-compiles and automatically picks up the changes, including scripts referenced from the Groovlet.
This is great for development, but I imagine that groovy must perform lots of file checks to see if any of the scripts have been modified, not just on the main Groovlet, but on all referenced sub-scripts. In a production environment, I imagine this could be lots of IO on every request.
I suppose there is a way to either disable having a Groovlet check to see if scripts have been modified, or perhaps there is a type of "update delay" like FreeMarker's setTemplateUpdateDelay() which only checks for modifications after N elapsed seconds/milliseconds since the last check.
This is done in GroovyScriptEngine. It checkes for the last modification date of the source file, and if it's newer than the compiled version, it will recompile.
You can set the minimumRecompilationInterval in CompilerConfiguration. If you set that to a very high value, the checking of the source file won't be done that often.

Typo3 Extbase Repository->findAll() returns empty

I just can't findAll() make return anything even though I am able to access a specific record by findByUid().
I have taken note (and tried to workaround / set up) of the typoscript solution and the record storage page bug without any success.
I am using a dummy extension code made by the extension builder in TYPO3 (current version) for your convenience. I have tested with data manually added through the TYPO3 config ui.
Any help would be much appreciated.
All the best and thanks in advance
Mario
For 99.9 % you didn't set your storagePid properly, it has to be the PID of the page where your records are stored. Effect: findAll() uses this PID to filter the records, while findByUid(uid) ignores PID (it searches by UID wherever record is stored.
Go to the main page > Templates and make sure that you included TypoScript from your new ext, then go to constant editor and set proper PID of page with your records. Clear whole cache at the end!
Also you can debug your SQL statement like in this answer, most probably at the end of statement you'll see something like AND your_table_name.pid IN (0) which definitely means that you didn't set storagePid or you didn't clear the cache.

How to work with hook_nodeapi after image thumbnail creation with ImageCache

A bit of a followup from a previous question.
As I mentioned in that question, my overall goal is to call a Ruby script after ImageCache does its magic with generating thumbnails and whatnot.
Sebi's suggestion from this question involved using hook_nodeapi.
Sadly, my Drupal knowledge of creating modules and/or hacking into existing modules is pretty limited.
So, for this question:
Should I create my own module or attempt to modify the ImageCache module?
How do I go about getting the generated thumbnail path (from ImageCache) to pass into my Ruby script?
edit
I found this question searching through SO...
Is it possible to do something similar in the _imagecache_cache function that would do what I want?
ie
function _imagecache_cache($presetname, $path) {
...
...
// check if deriv exists... (file was created between apaches request handler and reaching this code)
// otherwise try to create the derivative.
if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) {
imagecache_transfer($dst);
// call ruby script here
call('MY RUBY SCRIPT');
}
Don't hack into imagecache, remember every time you hack core/contrib modules god kills a kitten ;)
You should create a module that invokes hook_nodeapi, look at the api documentation to find the correct entry point for your script, nodeapi works on various different levels of the node process so you have to pick the correct one for you (it should become clear when you check the link out) http://api.drupal.org/api/function/hook_nodeapi
You won't be able to call the function you've shown because it is private so you'll have to find another route.
You could try and build the path up manually, you should be able to pull out the filename of the uploaded file and then append it to the directory structure, ugly but it should work. e.g.
If the uploaded file is called test123.jpg then it should be in /files/imagecache/thumbnails/test123/jpg (or something similar).
Hope it helps.

Resources