001 package org.apache.jcs.engine.behavior;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import java.io.IOException;
023 import java.io.Serializable;
024 import java.rmi.Remote;
025 import java.util.Map;
026 import java.util.Set;
027
028 /**
029 * Used to retrieve and update non local caches, such as the remote and lateral caches. Unlike
030 * ICacheService, the methods here have a requester id. This allows us to avoid propagating events
031 * to ourself.
032 * <p>
033 * TODO consider not extending ICacheService
034 */
035 public interface ICacheServiceNonLocal<K extends Serializable, V extends Serializable>
036 extends Remote, ICacheService<K, V>
037 {
038 /**
039 * Puts a cache item to the cache.
040 * <p>
041 * @param item
042 * @param requesterId
043 * @throws IOException
044 */
045 void update( ICacheElement<K, V> item, long requesterId )
046 throws IOException;
047
048 /**
049 * Removes the given key from the specified cache.
050 * <p>
051 * @param cacheName
052 * @param key
053 * @param requesterId
054 * @throws IOException
055 */
056 void remove( String cacheName, K key, long requesterId )
057 throws IOException;
058
059 /**
060 * Remove all keys from the specified cache.
061 * <p>
062 * @param cacheName
063 * @param requesterId
064 * @throws IOException
065 */
066 void removeAll( String cacheName, long requesterId )
067 throws IOException;
068
069 /**
070 * Returns a cache bean from the specified cache; or null if the key does not exist.
071 * <p>
072 * Adding the requestor id, allows the cache to determine the sournce of the get.
073 * <p>
074 * @param cacheName
075 * @param key
076 * @param requesterId
077 * @return ICacheElement
078 * @throws IOException
079 */
080 ICacheElement<K, V> get( String cacheName, K key, long requesterId )
081 throws IOException;
082
083 /**
084 * Gets multiple items from the cache based on the given set of keys.
085 * <p>
086 * @param cacheName
087 * @param keys
088 * @param requesterId
089 * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
090 * data in cache for any of these keys
091 * @throws IOException
092 */
093 Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
094 throws IOException;
095
096 /**
097 * Gets multiple items from the cache matching the pattern.
098 * <p>
099 * @param cacheName
100 * @param pattern
101 * @param requesterId
102 * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
103 * data in cache matching the pattern.
104 * @throws IOException
105 */
106 Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
107 throws IOException;
108
109 /**
110 * Gets the set of keys of objects currently in the group.
111 * <p>
112 * @param cacheName the name of the cache
113 * @param groupName the name of the group
114 * @return a Set of group keys.
115 * @throws IOException
116 */
117 Set<K> getGroupKeys( String cacheName, String groupName )
118 throws IOException;
119
120 /**
121 * Gets the set of group names in the cache
122 * <p>
123 * @param cacheName the name of the cache
124 * @return a Set of group names.
125 * @throws IOException
126 */
127 Set<String> getGroupNames( String cacheName )
128 throws IOException;
129 }