Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gotimeout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dustin L. Howett
gotimeout
Commits
7e5ab491
Commit
7e5ab491
authored
Aug 09, 2013
by
Dustin L. Howett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s/EphemeralKeyValueStore/map/ becuase gotimeout.Map makes a lot more sense.
parent
8b569f29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
ephstore.go
ephstore.go
+19
-19
No files found.
ephstore.go
View file @
7e5ab491
...
...
@@ -4,26 +4,26 @@ import (
"time"
)
//
EphemeralStoreValue represents any value which may be stored in an EphemeralKeyValueStore
.
type
EphemeralStore
Value
interface
{}
//
MapValue represents any value which may be stored in an Map
.
type
Map
Value
interface
{}
//
EphemeralKeyValueStore
provides an expiring key-value store whose contents are not saved to disk.
//
Map
provides an expiring key-value store whose contents are not saved to disk.
// It acts in a manner not dissimilar from a map.
type
EphemeralKeyValueStore
struct
{
type
Map
struct
{
expirator
*
Expirator
values
map
[
string
]
EphemeralStore
Value
values
map
[
string
]
Map
Value
}
type
e
phemeralE
xpirationProxy
ExpirableID
type
expirationProxy
ExpirableID
func
(
e
e
phemeralE
xpirationProxy
)
ExpirationID
()
ExpirableID
{
func
(
e
expirationProxy
)
ExpirationID
()
ExpirableID
{
return
ExpirableID
(
e
)
}
// New
EphemeralKeyValueStore returns a new EphemeralKeyValueStore
whose expiration daemon is already running.
func
New
EphemeralKeyValueStore
()
*
EphemeralKeyValueStore
{
v
:=
&
EphemeralKeyValueStore
{
values
:
make
(
map
[
string
]
EphemeralStore
Value
),
// New
Map returns a new Map
whose expiration daemon is already running.
func
New
Map
()
*
Map
{
v
:=
&
Map
{
values
:
make
(
map
[
string
]
Map
Value
),
}
v
.
expirator
=
NewExpirator
(
""
,
v
)
...
...
@@ -31,31 +31,31 @@ func NewEphemeralKeyValueStore() *EphemeralKeyValueStore {
}
// Put places the given object into the key-value store and queues its expiration.
func
(
e
*
EphemeralKeyValueStore
)
Put
(
k
string
,
v
EphemeralStore
Value
,
lifespan
time
.
Duration
)
{
func
(
e
*
Map
)
Put
(
k
string
,
v
Map
Value
,
lifespan
time
.
Duration
)
{
e
.
values
[
k
]
=
v
e
.
expirator
.
ExpireObject
(
e
phemeralE
xpirationProxy
(
k
),
lifespan
)
e
.
expirator
.
ExpireObject
(
expirationProxy
(
k
),
lifespan
)
}
// Get returns the object referred to by the given key.
func
(
e
*
EphemeralKeyValueStore
)
Get
(
k
string
)
(
v
EphemeralStore
Value
,
ok
bool
)
{
func
(
e
*
Map
)
Get
(
k
string
)
(
v
Map
Value
,
ok
bool
)
{
v
,
ok
=
e
.
values
[
k
]
return
}
// Delete removes the object referred to by the given key from the key-value store and stays its execution.
func
(
e
*
EphemeralKeyValueStore
)
Delete
(
k
string
)
{
e
.
expirator
.
CancelObjectExpiration
(
e
phemeralE
xpirationProxy
(
k
))
func
(
e
*
Map
)
Delete
(
k
string
)
{
e
.
expirator
.
CancelObjectExpiration
(
expirationProxy
(
k
))
delete
(
e
.
values
,
k
)
}
func
(
e
*
EphemeralKeyValueStore
)
GetExpirable
(
id
ExpirableID
)
Expirable
{
func
(
e
*
Map
)
GetExpirable
(
id
ExpirableID
)
Expirable
{
_
,
ok
:=
e
.
values
[
string
(
id
)]
if
!
ok
{
return
nil
}
return
e
phemeralE
xpirationProxy
(
id
)
return
expirationProxy
(
id
)
}
func
(
e
*
EphemeralKeyValueStore
)
DestroyExpirable
(
ex
Expirable
)
{
func
(
e
*
Map
)
DestroyExpirable
(
ex
Expirable
)
{
delete
(
e
.
values
,
string
(
ex
.
ExpirationID
()))
}
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