edge

package module
v0.0.0-...-5cefb41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

Edge

Build Codecov Go Report Card GoDoc Sourcegraph

Edge is an open-source industrial-strength library for golang developer

Documentation

Overview

Package edge An open-source library for golang developer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Set saves value under the key, treat the key as nonexistent
	// If key already exist, old value will be return
	// If key not exist, nil will be return
	Set(key string, val interface{}) interface{}

	// Get reads value under the key.
	// If key not exist, < nil, false> will be return
	Get(key string) (value interface{}, ok bool)

	// Delete removes the key in cache
	// If key not exist, false will be return
	Delete(key string) (present bool)

	// Exists returns whether the key exists in the cache.
	Exists(key string) bool

	// Cap returns maximum capacity of the cache.
	Cap() int

	// Len returns how many keys are currently stored in the cache.
	Len() int
}

Cache is the common interface implemented by many kinds of cache algorithms

type ConsistentHash

type ConsistentHash interface {
	// Add Saves server node into hash
	Add(s Server)

	// Remove deletes server node from hash
	Remove(node Server)

	// Get returns an server node close to key hash.
	Get(key string) Server
}

ConsistentHash was first described in a paper, ["Consistent hashing and random trees: Distributed caching protocols for relieving hot spots on the World Wide Web (1997)"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.147.1879) by David Karger et al. It is used in distributed storage systems like Amazon Dynamo and memcached.

type Server

type Server interface {
	String() string
}

Server ConsistentHash uses String() as key when add into hash

Directories

Path Synopsis
Package lru implements lru algorithm using linked list and hash map
Package lru implements lru algorithm using linked list and hash map
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL