Giter Club home page Giter Club logo

zxkvstore's Introduction

ZXKVStore

ZXKVStore is an Key-vlaue database written in Swift.The data stored on disk from FMDB.

My homepage

Features

  • [√] key-value store
  • [√] counter
  • [√] switch

Requirements

  • iOS 7.0+ / Mac OS X 10.9+
  • Xcode 6.4

Installation

To use ZXKVStore with a project targeting iOS 7, you must include FMDB in your project.

  1. Import FMDB (it is recommended to use Cocoapods.)
  2. If you don't have an bridging header file,create one.(Because FMDB is writen in Objective-C.)
  3. Drag the ZXKVStore.swift into your project

Usage

key-value store

println(ZXKV["homepage"]) //nil        
ZXKV["homepage"] = "http://www.zhangxi.me"  // store a value to the key
println(ZXKV["homepage"]) //http://www.zhangxi.me

let array = ["abc","123"]
ZXKV["array"] = array
println(ZXKV["array"])  //["abc","123"]

//any object which implemented NSCoding can be stored.

Search

ZXKV.prefix("100") //Return Array<(key:String,value:AnyObject)> which key begins with prefix("100")

ZXKV.surfix("zx") //Return Array<(key:String,value:AnyObject)> which key ends with surfix("zx")

ZXKV.glob("*zx")  //Return Array<(key:String,value:AnyObject)> [GLOB](http://www.runoob.com/sqlite/sqlite-glob-clause.html)
ZXKV.like("%zx")  //Return Array<(key:String,value:AnyObject)> [LIKE](http://www.runoob.com/sqlite/sqlite-like-clause.html)


ZXKV.first()  //first inserted object
ZXKV.last()   //last inserted object

Counter

println(ZXKV.count("key"))       //0
println(ZXKV.increase("key"))    //1
ZXKV.setCount("key", value: 10)  //10
println(ZXKV.count("key"))       //10
println(ZXKV.decrease("key"))    //9
println(ZXKV.count("key"))       //9

Switch

println(ZXKV.switchState("key"))                   // nil
println(ZXKV.switchOn("key"))                      //true,means switch on sucess
println(ZXKV.switchState("key"))                   //true,the state is true
println(ZXKV.switchOff("key"))                     //true,means switch off success
println(ZXKV.switchState("key"))                   //false,means the state is false
println(ZXKV.setSwitchState("key", value: true))   //true,set the state to true,sucess
println(ZXKV.switchState("key"))                   //true,the state is true

FAQ

When should I use ZXKVStore?

If you're starting a new project in Swift, and just use swift in your old project.You may want to store some data.How? SQLite ? CoreData ? NSUserDefault ? All of this is ok.But you still have another choice , ZXKVStore.It's very light,just drag the ZXKVStore.swift to your project and ZXKV["key"] = value.

When should I use AFNetworking?

When you want to store data.

What's the origin of the name Alamofire?

ZXKVStore mean ZhangXi Key-value store.I'm zhangxi.


License

Alamofire is released under the MIT license. See LICENSE for details.

zxkvstore's People

Contributors

zhangxigithub avatar

Watchers

Carabineiro 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.