w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Cache with expiring keys
Yes, there is ActiveSupport::Cache::Store An abstract cache store class. There are multiple cache store implementations, each having its own additional features. See the classes under the ActiveSupport::Cache module, e.g. ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most popular cache store for large production websites. Some implementations may not support all methods beyond the basic cache methods of fetch, write, read, exist?, and delete. ActiveSupport::Cache::Store can store any serializable Ruby object. http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html cache = ActiveSupport::Cache::MemoryStore.new cache.read('Chicago') # => nil cache.write('Chicago', 2707000) cache.read('Chicago') # => 2707000 Regarding

Categories : Ruby On Rails

Cache dependency between two items in cache
Try this Cache["UserName"] = "Test User"; // Make Cache["Message"] dependent on Cache["UserName"]. string[] dependencyKey = new string[1]; dependencyKey[0] = "UserName"; CacheDependency dependency = new CacheDependency(null, dependencyKey); Cache.Insert("Message", "Test Message", dependency);

Categories : Asp Net

How to convert 10-minute time blocks to 1-minute intervals in R
Just merge your xts object with the sequence of times you want. Data <- structure(list(datetime=structure(c(1322641920, 1322642520, 1322643120, 1322643720, 1322644320, 1322644920, 1322645520), class=c("POSIXct", "POSIXt"), tzone=""), count=c(100L, 60L, 10L, 10L, 200L, 180L, 190L)), .Names=c("datetime", "count"), row.names=c(NA, -7L), class="data.frame") data_xts <- as.xts(Data[,-1], order.by=Data$datetime) data_xts <- merge(data_xts, seq(start(data_xts)-60*9, end(data_xts), by="1 min")) Then you can use na.locf or similar to fill in the missing values, if you want. data_xts <- na.locf(data_xts)

Categories : R

How to read all the items present in an Appfabric Cache:
There is no built-in method to list all items in the cache. You're correct, it's possible to list all items using GetObjectsInRegion for a named cache. You have to know first all regions names (if used) or call GetSystemRegions to get all (default) system regions. A simple foreach will allow you to list all items. When you put something into the cache without region name, it will be added to a system region. Here is a basic example // Declare array for cache host(s). DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1]; servers[0] = new DataCacheServerEndpoint("YOURSERVERHERE", 22233); // Setup the DataCacheFactory configuration. DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration(); factoryConfig.Servers = servers;

Categories : Misc

Dropdown select with thousands of items.. cache, ajax, or both?
Probably dropdown is not such a good idea in such case. Perhaps a grid with paging? If you absolutely must to use dropdown - cache the query results (in a table on the DB side if result set is too big or in-memory cache on Web server otherwise) and use a drop down that supports typeahed, so when user types a few characters - only relevant relevant records are displayed.

Categories : Ajax

Find key using lambda expression in HttpContext.Current.Items cache
The Items property is an IDictionary, so you'd have to do this: public IEnumerable<string> GetKey (Func<string, bool> condition) { return HttpContext.Current.Items .Cast<DictionaryEntry>() .Where(e => e.Key is string && e.Value is string && condition(e.Key as string)) .Select(e => e.Value as string); } or in query syntax: public IEnumerable<string> GetKey (Func<string, bool> condition) { return from e in HttpContext.Current.Items.Cast<DictionaryEntry>() where e.Key is string && e.Value is string && condition(e.Key as string) select e.Value as string; } Update I miss-read the question

Categories : C#

nodejs - every minute, on the minute
You shouldn't do that, because with this while you will have a blocking operation. Also, there are better things to do in any JavaScript platform, like using setInterval/setTimeout functions. The node docs for them are here. A quick example of how to achieve what you want: setInterval(function() { Date date = new Date(); if ( date.getSeconds() === 0 ) { DoSomething(); } }, 1000); For a more fine grained control over scheduled processes in Node, maybe you should checkout node-cron.

Categories : Node Js

Why does REDIS key keep expiring?
Redis keys do not have a default expiration date. Are you sure there is nothing deleting your key? Can you check if your Redis server gets restarted? Are you using any form of persistance on the Redis data set?

Categories : Ruby On Rails

How does an iOS app keep a FBSession from expiring?
By using the FBSession with a token, that token will be extended automatically with the newest SDK: https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBSession.m#L236-L260

Categories : IOS

Self expiring object - any better alternative
Just calculate the expiry lazily: private long expiryDate; // set in constructor public boolean isExpired() { return System.currentTimeMillis() >= expiryDate; } No need to spawn a thread.

Categories : Java

AngularJS: Expiring cookies?
You could create a cookie from standard JavaScript from within an Angular Ctrl using window.document.cookie. https://developer.mozilla.org/en-US/docs/Web/API/document.cookie Example from documentation: document.cookie = "someCookieName=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";

Categories : Angularjs

Expiring a javascript variable?
Assuming the actual variable actually exists that long (the page stays open), just do what every cache does: save a timestamp and check for it. var cache = { timestamp : null, data : null }; function setData(data) { cache.data = data; cache.timestamp = new Date; } function getData(maxAge) { if (/* compare cache.timestamp to now - maxAge */) { return null; } return cache.data; }

Categories : Javascript

Session Expiring in ASP.net After refreshing any page
See this link. I think this might helps you. http://www.schnieds.com/2009/07/aspnet-session-expiration-redirect.html http://geekswithblogs.net/shahed/archive/2007/09/05/115173.aspx

Categories : C#

CakePHP Expiring Headers (Plugins)
Please, check plugin assets seems all your plugin static files handled by dispatcher this is reason of wrong headers. So, try to lead official documentation and create symbolic link

Categories : PHP

Session expiring on Safari Mobile
I found the answer in another question, but as a reference i´ll copy it (the other question is phrased towards another problem but the solution is the same) This is for rails 3.x so the solution is to set the expire time in every request like this: class ApplicationController < ActionController::Base after_filter :short_session ... def short_session request.session_options = request.session_options.dup request.session_options[:expire_after] = 1.minute request.session_options.freeze end This is the original answer where this code was taken. How to I dynamically set the expiry time for a cookie-based session in Rails And yes this fixes the issue with webapp mode in iOS not saving the session.

Categories : Ruby On Rails

Private bucket and expiring URLs
Make sure you don't have a bucket policy attached to that bucket that gives everyone permissions to read your files. Also check the ACLs for each file and remove any public-read permissions. Check the S3 docs for more info: http://docs.aws.amazon.com/AmazonS3/latest/dev/ACLOverview.html http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingResOpsConditions.html

Categories : PHP

Make expiring image or html
Assuming you currently have a custom post type archive template (by default, if your custom post type is named "artwork" it would be archive-artwork.php, you could create a check for the date it was published using the_date() function like so: // expiration date is a rolling date from 30 days ago $expiration_date = date('Ymd', strtotime("-30 days")); // use the_date( $format, $before, $after, $echo ) to get the current post's // date in the loop $post_date = the_date('Ymd', '', '', false); // compare the dates and output different markup or classes to your HTML if ($post_date < $expiration_date) { echo '<div class="expired-post">'; } else { echo '<div class="new-post">'; }

Categories : Wordpress

Asp.net MVC 3 session not expiring on expected time
Make sure you have disabled sliding expiration: <system.web> <sessionState mode="InProc" timeout="2" /> <authentication mode="Forms"> <forms loginUrl="/Home/Login" timeout="2" slidingExpiration="false" /> </authentication> </system.web> Now no matter whether you are sending requests to the application during the period, the forms authentication cookie won't be renewed.

Categories : Asp Net

Remove cookie by expiring it not working
"You cannot directly delete a cookie on a user's computer. However, you can direct the user's browser to delete the cookie by setting the cookie's expiration date to a past date. The next time a user makes a request to a page within the domain or path that set the cookie, the browser will determine that the cookie has expired and remove it." Please read the following article for more detail. http://msdn.microsoft.com/en-us/library/ms178195(v=vs.85).aspx

Categories : Asp Net Mvc

Google Maps Android API v2 expiring dev API key
One maps key can easily work with multiple certificates, which allows you to have one Google Maps key, and do not bother which certificate your app is currently signed with. To assign more certificates to one Google Maps key, simply put certificate hash and package name in separate line, i.e.: AA:BB:CC.......;com.webnetmobile.test XX:DD:ZZ.......;com.webnetmobile.test where AA:BB:CC... is certificate hash. One entry is for your debug certificate another for production. You can also edit current key, to add new entries, so no need to recreate (unless you sure that's mandatory)

Categories : Android

Session Variables not expiring with iOS, bootstrap and codeigniter
Apparently that's already set in the config file in codeigniter See more here: http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

Categories : PHP

Expiring a cached item via CacheItemPolicy in .NET MemoryCache
Caching adheres to UTC time to offer uniform time calculations, so you specify a point in time at which the cached entry should expire, in UTC, and the cache will calculate the appropriate difference from now and expire it as expected. Your code will not work as expected since your absolute expiration will be after your cache item is entered once cacheExpiryInSeconds seconds pass, resulting in immediate eviction. You cannot share a CacheItemPolicy instance when AbsoluteExpiration is set in the near future, annoying I know. :)

Categories : C#

$_SESSION cookies not expiring when browser is closed
As of your code, session_set_cookie_params() isn't called in any case. Therefore I propose to do this: session_set_cookie_params(0); session_start(); if (isset($_POST['username']) && isset($_POST['password'])) { ... Note, that's actually useful to call session_set_cookie_params() always for session cookies. Generate a new session-ID at each user level change To protect your applications against attackers, it is absolutely required to change the sessionID after each change of the role of a user: Anonymous user -> Logged in user Logged in user -> anonymous user Logged in user -> Administrative logged in user ... Thus, if user gets logged in or logged off, please regenerate the session ID like so: session_regenerate_id( true ); Have a look in OWASP's PHP security chea

Categories : PHP

How to keep cookies from expiring even after browser restart in CakePHP application
update session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params(). I think setting your session.cookie_lifetime to such a high value will mean you will have many stale sessions on your server and this might be a issue if you have large numbers of sessions - typically sessions are stored in the system's /tmp folder. When this folder, typically on *nix machines, fills up it could cause problems on the machine - processes start locking up as they fail to create temporary files for whatever reason. (You can change the session.save_path to something other than /tmp so you don't have this issue - especially on shared hos

Categories : PHP

How do I create and save an expiring user token in node js?
First, the user token should be a Model: var mongoose = require( 'mongoose' ); var Schema = mongoose.Schema; var Token = new Schema({ token: {type: String}, createDate: {type: Date, default: Date.now} }); Token.methods.hasExpired= function(){ var now = new Date(); return (now - createDate) > 7; //token is a week old }; //don't forget to add the token as a field in your user mongoose.model( 'Token', Token); Next, in the router, inside the else clause, I would change your findOneAndUpdate to findOne, because you are not updating the whole User object, but simply a property on it. require('crypto').randomBytes(48, function(ex, buf) { var userToken = buf.toString('hex'); User.findOne({email: (req.body.email)}, function(err, usr) { if(err || !usr) {

Categories : Node Js

GAE Application needing to create Expiring Signed URL's to Google Cloud Storage
Using storage.cloud.google.com is requesting cookie based authenticated downloads. Changing: String baseURL = "https://storage.cloud.google.com/myproj/foo.txt" to String baseURL = "https://storage.googleapis.com/myproj/foo.txt" should work better. I'm not sure why you're only seeing this when using the URL created via App Engine. Maybe you're not logged in to Google when testing the App Engine application? Or running it in the local dev server? See the reference URIs section of the docs for details on possible request URIs.

Categories : Google App Engine

Using Redis as the Spring cache manager in order to cache custom java objects
You can start by looking at Spring Data Redis, but unlike Spring Data JPA, is doesn't offer repository abstraction, instead using Spring templates with accessor methods specific only to redis. Since Redis does not support relations, you'll have to design and implement these relations by overriding JPA's standard CRUD operations. Here's a great article that details something up your alley... http://www.packtpub.com/article/building-applications-spring-data-redis I am new to Redis and it seems Redis is only able to cache the basic types/structures it knows (strings, hashes, etc.) Redis can store anything; text, json, binary data, it doesn't matter. By default, RedisTemplate (part of Spring Data Redis), uses Java serialization to marshal/unmarshall objects to/from redis, but it uses

Categories : Spring

Amazon Cloudfront Cache-Control: no-cache header has no effect after 24 hours
Verify that the CloudFront distribution's Minimum TTL is set to 0. If it's set to any other value, CloudFront won't respect the no-cache header and will still cache the file for the Minimum TTL. More details about the caching directives can be found here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html If this doesn't help, try to debug the actual HTTP request for index.html and post the response headers here so we can have a look at them. Also, instead of using no-cache for the index.html file, you can try using public, must-revalidate, proxy-revalidate, max-age=0 This will allow CloudFront to store the file on the edge location, but it will force it to revalidate it with the origin with each request. If the file hasn't changed, CloudFront will not

Categories : Caching

Is it possible to create multiple cache stores using Spring's cache abstraction with redis?
According to the docs the RedisCacheManager by default saves the keys directly, without appending a prefix (cache name, which acts as a namespace). To change it and avoid clashes set 'usePrefix' to 'true': http://static.springsource.org/spring-data/data-redis/docs/current/api/org/springframework/data/redis/cache/RedisCacheManager.html

Categories : Spring

hibernate second level cache using jboss cache in clustered environment
I believe your problem is that you have 2 jgroups clusters setup (the cluster for the app server and the cluster for the treecache) and both clusters have the same partition name "MyPartition". You need to configure a different partition name for the treecache cluster config.

Categories : Java

com.google.common.cache.Cache class not found error
Obvious answer is that; The Google guava jar is not found from the classpath dictated by the application server. The jar should be present in either WEB-INF/classes or WEB-INF/lib. Apache Tomcat also loads common classes from $CATALINA_HOME/lib folder.

Categories : Java

Can we cache images, css and java script in MVC3 through Output Cache?
Instead of Output Cache attribute you can use following methods to have caching of static resources: 1.Using max-age. Put below section in web.config in <configuration> -> <system.webServer> section <staticContent> <!-- Tell client to cache static files for a year --> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /> </staticContent> 2.Using URL versioning. Can be done by bundling. If you are using MVC3 you could look at combres on nuget. In MVC4 or above it is build-in option: Bundling and Minification

Categories : Asp Net Mvc

imageNamed and imageWithContentsOfFile cache image: Anyway to clear cache?
Is it possible that you are adding multiple separate UIImageViews? I.e. you are adding a local variable named detailImageView to your superview one time when this method is called, and then later on you call this method again and a new local variable UIImageView named detailImageView is added to the superview on top of the old one? If this is this case, you should see [self.view.subviews count] increasing as the method is called multiple times, adding multiple UIImageViews. In that case, you need to remove the old UIImageView before adding a new one.

Categories : IOS

Google Volley - when to use Cache.remove and Cache.invalidate
Remove means you are removing the actual cached data. Invalidate means you are just marking the data as invalid. So volley will check with the server whether the data is still valid. The full expire determines whether to use the data before volley has validated it with the server. More details in the source: https://android.googlesource.com/platform/frameworks/volley/+/master/src/main/java/com/android/volley/Cache.java

Categories : Android

How can I find location of evicted cache line in L2 cache?
Im not aware of answer to your entire question. But there is no way to know which cache line your data is mapped to. Because you dont the set number to which your data/address is mapped in L2 cache.! But I think you can know this if you are using HUGE PAGES which lets you know the mapping to L2 clearly.

Categories : C++

Browser cache- not understanding the cache related headers
Its mostly legacy, though some headers do subtly different things. Different browsers work differently (certainly in the past), and there wasn't always a standard way of doing things. Eg. IE 6 won't respond to modern caching headers. To make sure a site works correctly, we have to consider older browsers (at least for now). Have a look at this page for some good information.

Categories : HTML

Set the path of the symfony2 cache files during cache:clear
You could create a custom Symfony environment called "deploy" for your deployment and then override the different cache folders. Once you have your new environment (named "deploy" in the example below), you could override the method getCacheDir of the class app/AppKernel.php to something like this public function getCacheDir() { if ($this->environment === "deploy") { return '/the/path/to/your/symfony/cache/'.$this->environment; } else { return $this->rootDir.'/cache/'.$this->environment; } } Make sure the environment is only accessible locally by trusted users.

Categories : Symfony2

Is there a way to get all of the keys out of a cache in Angular, specifically the template cache?
Since the cacheFactory implements a self-contained LRU cache, you don't need to peek at the keys since you can always to use .get() to try to get the value. You will either hit or miss the cache. I created a peek() function and submitted a patch.

Categories : Javascript

How to cache files over 1MB with rack/cache on Heroku?
So contrary to @jordelver's question, I find that setting the :value_max_bytes option of dalli does work. I'm setting up Rack::Cache in a slightly different way that maybe makes the difference. This is what my production.rb contains to configure Rack::Cache: client = Dalli::Client.new(ENV["MEMCACHIER_SERVERS"], :username => ENV["MEMCACHIER_USERNAME"], :password => ENV["MEMCACHIER_PASSWORD"], :value_max_bytes => 10485760) config.action_dispatch.rack_cache = { :metastore => client, :entitystore => client } config.static_cache_control = "public, max-age=2592000" With the above, some errors will be printed to the logs for values over 1MB, but they won't cause a 5xx error for the client,

Categories : Ruby On Rails

How to send cache-control: no-cache from mobile?
As i know, just three options available on different browsers: Slide down Settings -> Refresh Settings -> Privacy -> Clear cache (All/For this site only) If 1 and 2 doesn't help you just make extra click to clear cache manually UPDATE: Ok I check safari and chrome at this site: it seems like you cannot send pragma: no-cache, from browser, only programmatically via meta tags, so there is no way to do it

Categories : Caching



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