GithubHelp home page GithubHelp logo

tmp-data's Introduction

tmp kvs

一時的なKVS形式のデータを取り扱う際のユーティリティ

Usage

$tmpData = new \TmpData\TempDataProvider([
    "tableName" => "tmp_token",
    "dns" => "mysql://hogehoge"
]);

$tmpData->set($key,$value); // write data

$token = $tmpData->pickUp($key); //read data and update timestamp
$token = $tmpData->read($key); //just read data

//token will be null or \Chatbox\TempData Object

if($token->isUsable()){ // check if token in term
    $key = $token->key;
    $value = $token->value;
    $createdAt = $token->createdAt;
    $updatedAt = $token->updatedAt;
    $expiredAt = $token->expiredAt;
    $accessedAt = $token->accessedAt;
    $deletedAt = $token->deletedAt;
}

$token->update($value); // update data
$token->delete(); // soft delete

$tmpData->flush(); // delete all data

schema

key string value string createdAt timestamp updatedAt timestamp accessedAt timestamp expiredAt timestamp deletedAt timestamp

Simply you can use \Chatbox\TmpData\SchemaBuilder to generate Builder Closure

# in laravel4

Schema::create('tmp_token', new \Chatbox\TmpData\SchemaBuilder());

Schema::create('tmp_confirm_mail', new \Chatbox\TmpData\SchemaBuilder([
    "useAccessedAt" => false,
    "defaultExpiredAt" => "200000",
]));

[ "cb_room" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->string("srug"); $table->unsignedInteger("tenants"); $table->text("prop"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, "cb_room_tag" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->unsignedInteger("room_id"); $table->string("type"); $table->string("value"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, "cb_user" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->string("name"); $table->string("enter_key"); $table->text("prop"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, "cb_user_tag" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->unsignedInteger("user_id"); $table->string("type"); $table->string("value"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, "cb_tenants" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->unsignedInteger("room_id"); $table->unsignedInteger("user_id"); $table->boolean("is_kicked"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, "cb_message" => function(Blueprint $table){ $table->unsignedInteger("id",true); $table->unsignedInteger("room_id"); $table->unsignedInteger("user_id"); $table->string("type"); $table->text("message"); $table->dateTime("created_at"); $table->dateTime("updated_at"); }, ], "seeds" => [ ["master_user",function(Builder $builder){ $builder->insert([ "name"=>"Tom", "sex" => "1" ]); }], ], "include" => [ "user" => __DIR__."/data/user.php" ] ];

tmp-data's People

Watchers

James Cloos avatar みかかね avatar chatbox.inc 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.