/hazelcast/src/main/java/com/hazelcast/core/MapStore.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 68 lines · 9 code · 6 blank · 53 comment · 0 complexity · 5f9c94111c45f3e46a7a254dad977618 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.hazelcast.core;
  17. import java.util.Collection;
  18. import java.util.Map;
  19. /**
  20. * Hazelcast distributed map implementation is an in-memory data store but
  21. * it can be backed by any type of data store such as RDBMS, OODBMS, or simply
  22. * a file based data store.
  23. * <p/>
  24. * IMap.put(key, value) normally stores the entry into JVM's memory. If MapStore
  25. * implementation is provided then Hazelcast can also call the MapStore
  26. * implementation to store the entry into a user defined storage such as
  27. * RDBMS or some other external storage system. It is completely up to the user
  28. * how the key-value will be stored or deleted.
  29. * <p/>
  30. * Same goes for IMap.remove(key)
  31. * <p/>
  32. * Store implementation can be called synchronously (write-through)
  33. * or asynchronously (write-behind) depending on the configuration.
  34. */
  35. public interface MapStore<K, V> extends MapLoader<K, V> {
  36. /**
  37. * Stores the key-value pair.
  38. *
  39. * @param key key of the entry to store
  40. * @param value value of the entry to store
  41. */
  42. void store(K key, V value);
  43. /**
  44. * Stores multiple entries. Implementation of this method can optimize the
  45. * store operation by storing all entries in one database connection for instance.
  46. *
  47. * @param map map of entries to store
  48. */
  49. void storeAll(Map<K, V> map);
  50. /**
  51. * Deletes the entry with a given key from the store.
  52. *
  53. * @param key key to delete from the store.
  54. */
  55. void delete(K key);
  56. /**
  57. * Deletes multiple entries from the store.
  58. *
  59. * @param keys keys of the entries to delete.
  60. */
  61. void deleteAll(Collection<K> keys);
  62. }