Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
8ee9ee99
Commit
8ee9ee99
authored
Apr 02, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ListKeys method to Store
parent
3fe17b93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
store.go
pkg/client/cache/store.go
+13
-0
undelta_store.go
pkg/client/cache/undelta_store.go
+10
-0
No files found.
pkg/client/cache/store.go
View file @
8ee9ee99
...
@@ -37,6 +37,7 @@ type Store interface {
...
@@ -37,6 +37,7 @@ type Store interface {
Update
(
obj
interface
{})
error
Update
(
obj
interface
{})
error
Delete
(
obj
interface
{})
error
Delete
(
obj
interface
{})
error
List
()
[]
interface
{}
List
()
[]
interface
{}
ListKeys
()
[]
string
Get
(
obj
interface
{})
(
item
interface
{},
exists
bool
,
err
error
)
Get
(
obj
interface
{})
(
item
interface
{},
exists
bool
,
err
error
)
GetByKey
(
key
string
)
(
item
interface
{},
exists
bool
,
err
error
)
GetByKey
(
key
string
)
(
item
interface
{},
exists
bool
,
err
error
)
...
@@ -195,6 +196,18 @@ func (c *cache) List() []interface{} {
...
@@ -195,6 +196,18 @@ func (c *cache) List() []interface{} {
return
list
return
list
}
}
// ListKeys returns a list of all the keys of the objects currently
// in the cache.
func
(
c
*
cache
)
ListKeys
()
[]
string
{
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
list
:=
make
([]
string
,
0
,
len
(
c
.
items
))
for
key
:=
range
c
.
items
{
list
=
append
(
list
,
key
)
}
return
list
}
// Index returns a list of items that match on the index function
// Index returns a list of items that match on the index function
// Index is thread-safe so long as you treat all items as immutable
// Index is thread-safe so long as you treat all items as immutable
func
(
c
*
cache
)
Index
(
indexName
string
,
obj
interface
{})
([]
interface
{},
error
)
{
func
(
c
*
cache
)
Index
(
indexName
string
,
obj
interface
{})
([]
interface
{},
error
)
{
...
...
pkg/client/cache/undelta_store.go
View file @
8ee9ee99
...
@@ -49,6 +49,7 @@ func (u *UndeltaStore) Add(obj interface{}) error {
...
@@ -49,6 +49,7 @@ func (u *UndeltaStore) Add(obj interface{}) error {
u
.
PushFunc
(
u
.
ActualStore
.
List
())
u
.
PushFunc
(
u
.
ActualStore
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
Update
(
obj
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Update
(
obj
interface
{})
error
{
if
err
:=
u
.
ActualStore
.
Update
(
obj
);
err
!=
nil
{
if
err
:=
u
.
ActualStore
.
Update
(
obj
);
err
!=
nil
{
return
err
return
err
...
@@ -56,6 +57,7 @@ func (u *UndeltaStore) Update(obj interface{}) error {
...
@@ -56,6 +57,7 @@ func (u *UndeltaStore) Update(obj interface{}) error {
u
.
PushFunc
(
u
.
ActualStore
.
List
())
u
.
PushFunc
(
u
.
ActualStore
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
Delete
(
obj
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Delete
(
obj
interface
{})
error
{
if
err
:=
u
.
ActualStore
.
Delete
(
obj
);
err
!=
nil
{
if
err
:=
u
.
ActualStore
.
Delete
(
obj
);
err
!=
nil
{
return
err
return
err
...
@@ -63,15 +65,23 @@ func (u *UndeltaStore) Delete(obj interface{}) error {
...
@@ -63,15 +65,23 @@ func (u *UndeltaStore) Delete(obj interface{}) error {
u
.
PushFunc
(
u
.
ActualStore
.
List
())
u
.
PushFunc
(
u
.
ActualStore
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
List
()
[]
interface
{}
{
func
(
u
*
UndeltaStore
)
List
()
[]
interface
{}
{
return
u
.
ActualStore
.
List
()
return
u
.
ActualStore
.
List
()
}
}
func
(
u
*
UndeltaStore
)
ListKeys
()
[]
string
{
return
u
.
ActualStore
.
ListKeys
()
}
func
(
u
*
UndeltaStore
)
Get
(
obj
interface
{})
(
item
interface
{},
exists
bool
,
err
error
)
{
func
(
u
*
UndeltaStore
)
Get
(
obj
interface
{})
(
item
interface
{},
exists
bool
,
err
error
)
{
return
u
.
ActualStore
.
Get
(
obj
)
return
u
.
ActualStore
.
Get
(
obj
)
}
}
func
(
u
*
UndeltaStore
)
GetByKey
(
key
string
)
(
item
interface
{},
exists
bool
,
err
error
)
{
func
(
u
*
UndeltaStore
)
GetByKey
(
key
string
)
(
item
interface
{},
exists
bool
,
err
error
)
{
return
u
.
ActualStore
.
GetByKey
(
key
)
return
u
.
ActualStore
.
GetByKey
(
key
)
}
}
func
(
u
*
UndeltaStore
)
Replace
(
list
[]
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Replace
(
list
[]
interface
{})
error
{
if
err
:=
u
.
ActualStore
.
Replace
(
list
);
err
!=
nil
{
if
err
:=
u
.
ActualStore
.
Replace
(
list
);
err
!=
nil
{
return
err
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment