Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting absolute local path to a cached file
#1
I'm adding temp files using something like:

sTempFileName := TIWAppCache.StreamToCacheFile(self, ...

And sTempFileName works fine as a URI (i.e.: in a IWURLWindow1.URI), because it's a valid relative URI.

But I need to get a local absolute path to this file in the server-side code, hopefully easier than parsing WebApplication.UserCacheDir, etc.

Is there a direct way of doing this?
Reply
#2
Actually, this may not be very reliable, because these .tmp files have internal caching data appended to them. So I'll need to reshuffle all this anyway.
Reply
#3
Correct, they do have info in them.
Reply
#4
The source code can offer you a stream from them though and it removes the extra info if you can use a stream instead of a file itself.
Reply
#5
(02-11-2022, 12:22 AM)kudzu Wrote: The source code can offer you a stream from them though and it removes the extra info if you can use a stream instead of a file itself.

That would be great, thanks, because I can. What object.method is it in?
Reply
#6
The cache file is stored in

ServerController.CacheDir

http://docs.atozed.com/docs.dll/classes/...rBase.html

Regarding the cache, there is some information here:

http://docs.atozed.com/docs.dll/developm...html#Cache

and here

http://docs.atozed.com/docs.dll/Classes/...Cache.html
Reply
#7
(02-14-2022, 06:07 AM)Alexandre Machado Wrote: The cache file is stored in

ServerController.CacheDir

http://docs.atozed.com/docs.dll/classes/...rBase.html

Regarding the cache, there is some information here:

http://docs.atozed.com/docs.dll/developm...html#Cache

and here

http://docs.atozed.com/docs.dll/Classes/...Cache.html

Ok, thanks. BUt I cannot see how to get a stream of an already cached file. All these methods would create a cache file from my stream, I need the reverse.
Reply
#8
There is a rule of thumb with the cache system: once you add something to the cache, you should just forget about it... :-)
It doesn't belong to you anymore. The cache file is not only the data that you put in there. It is your data + some metadata containing important information about the cache file itself.

Can you please explain why do you need to read the cache file after you saved your own data to it? Wouldn't be easier to read/store this data before adding it to the cache?
Reply
#9
(02-24-2022, 10:14 AM)Alexandre Machado Wrote: There is a rule of thumb with the cache system: once you add something to the cache, you should just forget about it... :-)
It doesn't belong to you anymore. The cache file is not only the data that you put in there. It is your data + some metadata containing important information about the cache file itself.

Can you please explain why do you need to read the cache file after you saved your own data to it? Wouldn't be easier to read/store this data before adding it to the cache?

My problem is that I'm creating these files elsewhere first and then later I may need them again, but here I do not want to re-acquire them all over again from where I got them in the first place. So, because I have already created these caches, it would be ideal for me to use them.

Interestingly enough, I could still use the files as they are, with the appended IW details, it does not seem to cause me any problems, but I suppose that it could. These caches are also good for me in that I do not need any extra maintenance in terms of deleting them in the end, IW does this for me already.

So, if I have to re-read the data and create duplicate files (which is a performance hit and a duplication of effort), I would then also have to remember to delete them in the end. Which is what I'm trying to avoid.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)