I have cached some domain instances and queries in my grails application. I would expect that after the first time the queries are fired to db, the subsequent calls will only hit cache.
But, I am seeing that periodically the queries hit db (after every 5-6 times). No data is getting updated/inserted into database in the mean time. I am using p6spy to check out all the queries that are logged and do not see any updates or inserts happening.
Is there any additional settings I need to tweek?
Currently domain class has
static mapping = {
cach true
}
Queries like findBy* have the [cache:true] set.
If you don't configure Ehcache, your caches will use the default timeout of 120 seconds. See http://ehcache.org/ehcache.xml for a well-commented example file that's the same as the default file that's in the Ehcache jar.
You can configure timeouts, max elements in memory, whether to spill over to disk, etc. by creating an ehcache.xml in your application. Put it in src/java and it will be copied into the classpath, and Ehcache will see it and use yours instead of its defaults.
Related
I am having a problem with the Oracle Rest Data Services (short ORDS) and I can't find a solution.
The Problem is as follows:
We are using ORDS via a TomCat Webserver and I have 2 Endpoints defined, one to Update a dataset and one to get all datasets from this table.
If I update the value via my Endpoint the change is written in the Table, but if I try to get the table with this change ORDS only response with the old not changed table. After a certain period of Time while constantly trying to get the change it repondes with the expected values. (happens after max 1 minute, can be earlier).
Because of this behaviour I accused some type of caching, but I cant find no configuration in the oracle database or on the TomCat.
Another Point for this theory was that I logged what happens in my GET procedure and found that only the one request with the correct values gets logged, like the others didnt even happen ..
The Request giving me the old value are coming back in the 4-8 ms range while the request with the correct data is in the 100-200 ms.
Ty for your help :)
I tried logging what happens, but I got that only the request with the fresh values was logged.
I tried to restart the TomCat Webserver to make sure that the cache is cleared, but this didnt fix the Problem
I searched for a configuration in ORDS or oracle where a cache would be defined, but it was never set.
I tried to set the value via a SQL update and not an endpoint, but even here I get the change only delayed
Do you have a full overview of the communication path? Maybe there is a proxy between?
When the TomCat has no caching configuration and you restartet the webserver during your tests and still have the same issue, then there is maybe more...
Kind regards
M-Achilles
I am working On a Microservice (Spring boot) that require to store some static information that infrequently changes (once per quarter). The data (below) is about the company reports that looks like
reportId#1: "frequency"="daily","to":"some email ids"
reportId#2: "frequency"="weekly", "to":"some emailids"
As you can see an entry in the data is basically a Report id, and associated attributes are frequency of reports and receiver's email id.
My question is.. What is the best place to store this information? I have some thoughts..and here are my views.
a) NoSQL DB like MongoDB seems to be a good option.. I can create a Collection and store it there and retrieve it once during app startup. But the I thought, whether creating a Collection just to store this static info is a good choice?
b) Redis seems to be another good option. I can create a template for above dataset and store it there. I can query the Redis based on the reportId to retrieve the frequency and senders list.
c) Store it in a file in the classpath and load at the app startup. The downside is that, I will have to redeploy the app with new changes in file whenever this report listing changes. I believe externalizing this information to either Mongo or Redis is a better option.
d) The app is running in the AWS..so I can even store this in a file in S3 bucket.
Would like to know your views?
Since the config will only change once a quarter, the overheard of a database is not required. You should consider Apache commons configuration. It will allow you to load config changes from files without the need for an application restart.
http://commons.apache.org/proper/commons-configuration///userguide/howto_reloading.html
Is there a need to have Redis snapshots when only using it as a session replication service with Spring Session? I read about Redis Persistence but it seems "persistence" only means backups, and that it is not fully required.
I have a problem in my application that no matter how many times I will call FLUSHALL, it will keep reloading old sessions somehow. I suspect from my RDB file.
Can I just define everything as memory only? Is there any reliability/performance benefits to use an RDB file at all?
I have a problem in my application that no matte how many times I will call FLUSHALL, it will keep reloading old sessions somehow. I suspect from my RDB file.
FLUSHALL will also remove data from RDB file. I think the data might be written by other processes after you called FLUSHALL.
Can I just define everything as memory only?
Yes, you can disable saving db to disk with config file. By default, Redis will save data to disk with some save directives in the config file. For example:
save 900 1
save 300 10
save 60 10000
To disable saving, just comment these save directives or add an empty save directive (i.e. save "").
# save 900 1
# save 300 10
# save 60 10000
Also you can disable AOF persistence logs with config file:
appendonly no
Is there any reliability/performance benefits to use an RDB file at all?
Reliability: Since Redis saves your data to disk, you can recover the data, when you restart Redis. However, if Redis is down accidently, you might lose some data, depends on your save directives in config file.
Performance: There's a performance penalty, especially when you are using RDB persistent with big data in memory.
You can get more details on Redis Persistence from its website.
What is the mechanism by which the cache and cache entries work? When is it that the data from the cache server is retrieved?
If a new client connects to Apache Ignite and calls the Ignite#getOrCreateCache() by passing in a name of cache that already exist, does the entire cache get downloaded?
After getting a reference to an existing cache and calling the IgniteCache#get("key") does only the value associated with the key gets returned or the entire cache?
The mechanism by which cache entries work is as follows:
You call IgniteCache#get(key) on a Ignite client. Ignite determines which is the closest server from where this key's value can be retrieved or if a near cache is enabled in the Ignite Client, then it checks if the key's value is present in the near cache or not.
The key's value is then serialized on the server side and sent across the network to your Ignite client(provided the value is not in near cache or the Ignite server is not on the same machine).
The Ignite Client De-serializes the value and returns the object.
Only the specific value is retrieved from the Ignite server and the entire cache is never downloaded on your client.
P.S. Whenever you ask questions related to Apache Ignite use the tags grid-gain and ignite.
In my application i'm using Infinispan 5.3 version and I want to change setting after cache is initialized. Default settings will be loaded from xml file and some of the settings ( ex : eviction maxEntries, lifespan, etc ) should be able to change any time of application running (This is changed by sysadmin). Is there way to changed settings of already created cache ?
I tried EmbeddedCacheManager.defineConfiguration(String cacheName, Configuration configurationOverride); but this has no effect on already created cache.
Please, take into account that in the Infinispan version 5.3 there is no possibility to change cache configuration "on the fly". You need to restart your service with new configuration in case of any wanted change.
This is something the community might want to work on in the future. However, such a task is not easy because you need to figure out how to correctly deal with affected data immediately after the configuration change.
Feel free to raise new feature request: https://issues.jboss.org/browse/ISPN/