public class GuavaSearchableResourceMetadataCache extends Object implements SearchableResourceMetadataCache, com.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>
GuavaResourceMetadataCache with support
for searching resources within the cache.
Cached entries are maintained two structures, a Guava Cache and a Radix Tree. The main caching
functionality is provided by the Guava Cache and the Radix Tree is used for searching by prefix.
The additional memory usage should be minimal since we only need to duplicate the keys, the nodes
references the same objects.
Both structures are kept in synch via a RemovalListener.| Constructor and Description |
|---|
GuavaSearchableResourceMetadataCache(long maxSize,
com.codahale.metrics.MetricRegistry registry) |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource) |
com.google.common.base.Optional<org.opennms.newts.cassandra.search.ResourceMetadata> |
get(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource) |
List<String> |
getResourceIdsWithPrefix(org.opennms.newts.api.Context context,
String resourceIdPrefix) |
long |
getSize() |
void |
merge(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource,
org.opennms.newts.cassandra.search.ResourceMetadata metadata) |
void |
onRemoval(com.google.common.cache.RemovalNotification<String,org.opennms.newts.cassandra.search.ResourceMetadata> notification) |
@Inject
public GuavaSearchableResourceMetadataCache(@Named(value="search.resourceMetadata.maxCacheEntries")
long maxSize,
@Named(value="newtsMetricRegistry")
com.codahale.metrics.MetricRegistry registry)
public com.google.common.base.Optional<org.opennms.newts.cassandra.search.ResourceMetadata> get(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource)
get in interface org.opennms.newts.cassandra.search.ResourceMetadataCachepublic void delete(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource)
delete in interface org.opennms.newts.cassandra.search.ResourceMetadataCachepublic void merge(org.opennms.newts.api.Context context,
org.opennms.newts.api.Resource resource,
org.opennms.newts.cassandra.search.ResourceMetadata metadata)
merge in interface org.opennms.newts.cassandra.search.ResourceMetadataCachepublic List<String> getResourceIdsWithPrefix(org.opennms.newts.api.Context context, String resourceIdPrefix)
getResourceIdsWithPrefix in interface SearchableResourceMetadataCachepublic void onRemoval(com.google.common.cache.RemovalNotification<String,org.opennms.newts.cassandra.search.ResourceMetadata> notification)
onRemoval in interface com.google.common.cache.RemovalListener<String,org.opennms.newts.cassandra.search.ResourceMetadata>public long getSize()
Copyright © 2021. All rights reserved.