Skip to content

Commit

Permalink
Merge pull request #192 from govau/govau
Browse files Browse the repository at this point in the history
Refactor caching
  • Loading branch information
shinji62 authored Jul 18, 2018
2 parents 56f6998 + 3e932a5 commit 62b9ecd
Show file tree
Hide file tree
Showing 33 changed files with 1,824 additions and 1,101 deletions.
17 changes: 7 additions & 10 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 28 additions & 2 deletions caching/caching.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package caching

import (
"errors"
"net/http"
"regexp"

cfclient "github.com/cloudfoundry-community/go-cfclient"
Expand All @@ -16,13 +18,37 @@ type App struct {
IgnoredApp bool
}

type Caching interface {
var (
// ErrKeyNotFound is returned if value is not found
ErrKeyNotFound = errors.New("key not found")
)

// CacheStore provides a mechanism to persist data
// After it has been opened, Get / Set are threadsafe
type CacheStore interface {
// Open initializes the store
Open() error

// Close closes the store
Close() error
GetAllApps() (map[string]*App, error)

// Get looks up key, and decodes it into rv.
// Returns ErrKeyNotFound if not found
Get(key string, rv interface{}) error

// Set encodes the value and stores it
Set(key string, value interface{}) error
}

type Caching interface {
FillCache() error
GetApp(string) (*App, error)
}

type CFSimpleClient interface {
DoGet(url string) (*http.Response, error)
}

type AppClient interface {
AppByGuid(appGuid string) (cfclient.App, error)
ListOrgs() ([]cfclient.Org, error)
Expand Down
Loading

0 comments on commit 62b9ecd

Please sign in to comment.