001/*
002 * Copyright (c) 2015 Maxim Yunusov
003 *    Licensed under the Apache License, Version 2.0 (the "License");
004 *    you may not use this file except in compliance with the License.
005 *    You may obtain a copy of the License at
006 *
007 *        http://www.apache.org/licenses/LICENSE-2.0
008 *
009 *    Unless required by applicable law or agreed to in writing, software
010 *    distributed under the License is distributed on an "AS IS" BASIS,
011 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 *    See the License for the specific language governing permissions and
013 *    limitations under the License.
014 */
015
016package org.maxur.perfmodel.backend.service;
017
018import org.iq80.leveldb.WriteBatch;
019
020import java.io.IOException;
021import java.io.Serializable;
022import java.util.Collection;
023import java.util.Optional;
024
025/**
026 * @author myunusov
027 * @version 1.0
028 * @since <pre>10.09.2015</pre>
029 */
030public interface DataSource {
031
032    <T> Optional<T> get(String key) throws IOException, ClassNotFoundException;
033
034    <T> Collection<T> findAllByPrefix(String prefix) throws IOException, ClassNotFoundException;
035
036    void delete(String key);
037
038    WriteBatch createWriteBatch();
039
040    void commit(WriteBatch batch);
041
042    void put(String key, Serializable value) throws IOException;
043}