GithubHelp home page GithubHelp logo

davidmr001 / bamboo-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from huacangliang/bamboo

0.0 1.0 0.0 155 KB

跨进程数据库持久化系统,独创竹节数据结构,让读写更快速。解决Android中的原生数据库经常发生各种意外问题

License: GNU General Public License v2.0

Java 100.00%

bamboo-1's Introduction

Bamboo

跨进程数据库持久化系统,独创竹节数据结构,让读写更快速。解决Android中的原生数据库经常发生各种意外问题

码云地址:Bamboo

本次修改:

  1. 修复中文存储错误
  2. 新增测试demo

/**
 * <p>竹子数据持久化系统,创意来源:因数据结构像竹子的节一样而得名</p>
 * <p>该系统应该配合数据缓存使用,因为直接操作io,会降低系统性能</p>
 * <p>理论上该数据支持物理最大化存储,数据结构应当保持不变,不变的前提是初始化数据的长度要尽量的合理,否则导致后面的长度变长而
 * 导致性能下降</p>
 * <p>该系统容量扩展会根据内容增加而增加,但是大小基本上跟数据大小一致</p>
 * <p>使用方式:
 * 先初始化
 *
 * @see Bamboo.init()
 * 再获取服务
 * @see Bamboo.getBambooServer().remove(key);
 * @see Bamboo.getBambooServer().read(key);
 * @see Bamboo.getBambooServer().write(key, value);
 * @see Bamboo.getBambooServer().cut(key)
 * @see Bamboo.getBambooServer().clearRef()
 * <p>
 * 系统优缺点:
 * 优点,支持多进程,对增量写友好,不耗费多余资源,对文件操作快速(因为基于随机读写)
 * 缺点:扩展实体长度困难,收缩缓慢
 * </p>
 */
public interface IBambooServer {
    /**
     * 保存数据,会覆盖前面的数据
     *
     * @param key
     * @param data
     * @return
     * @throws Exception
     */
    boolean write(String key, String data) throws Exception;

    /**
     * 读取数据,读取失败或没有值返回空字符“”
     *
     * @param key
     * @return
     * @throws Exception
     */
    String read(String key) throws Exception;

    /**
     * 删除数据,标记删除
     *
     * @param key
     * @return
     * @throws Exception
     */
    boolean cut(String key) throws Exception;

    /**
     * 移除数据实体,该函数很消耗io和计算资源,若无必要请不要使用
     *
     * @param key
     * @return
     * @throws Exception
     */
    boolean remove(String key) throws Exception;

    /**
     * 清除垃圾,该函数会删除被标记为删除的数据实体,相当耗费资源,请使用线程运行
     *
     * @return
     * @throws Exception
     */
    boolean clearRef() throws Exception;

    /**
     * 返回因各种意外导致的关闭状态
     *
     * @return
     */
    boolean isClose();
}

bamboo-1's People

Contributors

huacangliang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.