Giter Site home page Giter Site logo

go-cache's Introduction

go-cache

It is simple cache application with restful service.

Installation

go get -u github.com/gurkangul/go-cache

Options

Fields Description
CheckTime Expiration check every 1 second (default=1).You can change it.
IsLog Writing to file existing memory (default=false)
WriteTime if Islog is true. Writing to file every 5 seconds (default=5)
Port Listening port 3030 (default=3030)

IsLog

You want to write log. You must create log folder in your project directory.

mkdir log

Usage

package main

import (
	c "github.com/gurkangul/go-cache"
)

func main() {
	var cache = c.New(&c.Options{CheckTime: 1, IsLog: true})
	cache.Run()

}

set (POST request)

http://localhost:3030/set?key=foo&value=bar&expiration=60

Default expiration time is 60 second.(optional). You have to use key and value

Response (Status=201)

{
    "message": "success",
    "result": {
        "Expire": 1625333440,
        "Value": "bar",
        "Writed": false // if writed in log .It will be true
    },
    "success": true
}
//if missing key
{
    "message": "Url Param 'key' is missing",
    "result": null,
    "success": false
}

//if missing value
{
    "message": "Url Param 'value' is missing",
    "result": null,
    "success": false
}

// if use same key.
{
    "message": "foo already added",
    "result": null,
    "success": false
}

get (GET request)

http://localhost:3030/set?key=foo
{
    "message": "success",
    "result": {
        "Expire": 1625334965,
        "Value": "bar",
        "Writed": true // if writed in log .It will be true
    },
    "success": true
}
{
    "message": "Found nothing",
    "result": null,
    "success": false
}

go-cache's People

Contributors

gurkangul avatar

Watchers

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