I have an interesting problem.
I have 1 cache sensorsToSessions, mapping String to String, i.e. sensor id
-> session id.
When session is started I overwrite whatever is in the cache by the sensor
ids used in the current session, i.e.:
/sensorsToSessionsCache.putAll(sensorsToSessions);/
Also when the session is stopped I remove the items from the cache, i.e.:
/sensorsToSessionsCache.removeAll(sensorsIds);/
Connecting to the Ignite using Visor shows that it works (/cache -scan
-c=@c4/), i.e.
- after putting the items it prints:
visor> cache -scan -c=@c4
Entries in cache: sandbox.sensorsToSessions
+=======================================================================================+
| Key Class | Key | Value Class | Value
|
+=======================================================================================+
| java.lang.String | 50397794 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397793 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397783 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397776 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397846 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397828 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397817 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397812 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397811 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
| java.lang.String | 50397801 | java.lang.String |
4ae52f51-4c2a-11e6-a169-667afaa8cd5d |
+---------------------------------------------------------------------------------------+
- after removing the items it prints:
visor> cache -scan -c=@c4
Cache: sandbox.sensorsToSessions is empty
Although, this is where the issue is, doing /final String sessionId =
sensorsToSessionsCache.get(sensorId);/ always returns the previous session
id, i.ie from the log:
/Found sessionId df6f12a0-4c28-11e6-a169-667afaa8cd5d for sensorId 50397783/
So, no matter whether I overwrite the items, or remove them completely, and
even so, Visor proves it works, getting the item from the cache in the code
always returns previous value.
How it could be? Have I misconfigured the Ignite cluster? I am using
near-cache, btw, for the sensorsToSessionsCache.
There are 1 server node, and 2 clients nodes in the topology.
Also, if it helps, I have never seen the cache store was triggered for this
cache (at least I don't see anything in the log).
This is the cache config I am using:
<bean class="org.apache.ignite.configuration.CacheConfiguration"
p:name="sandbox.sensorsToSessions"
p:backups="0"
p:statisticsEnabled="true"
p:readThrough="true">
<property name="expiryPolicyFactory">
<bean class="javax.cache.expiry.CreatedExpiryPolicy"
factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration"
c:timeUnit="MINUTES"
c:durationAmount="120"/>
</constructor-arg>
</bean>
</property>
<property name="cacheStoreFactory">
<bean class="javax.cache.configuration.FactoryBuilder.ClassFactory"
c:clazz="com.application.grid.cache.store.SensorsToSessionsCacheStore"/>
</property>
</bean>
And this is how I @Inject/instantiate the cache instance into the
application components (so, essentially it creates the near cache for the
same server cache for the client nodes):
@Bean
@Qualifier("sensorsToSessionsCache")
public IgniteCache<String, String> sensorsToSessionsCache() {
final NearCacheConfiguration<String, String> nearCacheConfiguration
=
new NearCacheConfiguration<String, String>()
.setNearEvictionPolicy(
new
LruEvictionPolicy<>(cacheEnvironment.sensorsToSessionsNearCacheEvictionSize()))
.setNearStartSize(cacheEnvironment.sensorsToSessionsNearCacheStartSize());
return
ignite().createNearCache(cacheEnvironment.sensorsToSessionsCacheName(),
nearCacheConfiguration);
}
I am running Ignite 1.6.0 on Linux.
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Removing-or-overwriting-cache-value-but-still-able-to-get-it-from-the-cache-tp6334.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.