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
55238017
Commit
55238017
authored
Aug 09, 2013
by
Dustin L. Howett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gotimeout] ephstore makes more sense in gotimeout.
parent
589b51a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
ephstore.go
ephstore.go
+53
-0
No files found.
ephstore.go
0 → 100644
View file @
55238017
package
gotimeout
import
(
"time"
)
type
EphemeralStoreValue
interface
{}
type
EphemeralKeyValueStore
struct
{
expirator
*
Expirator
values
map
[
string
]
EphemeralStoreValue
}
type
ephemeralExpirationProxy
ExpirableID
func
(
e
ephemeralExpirationProxy
)
ExpirationID
()
ExpirableID
{
return
ExpirableID
(
e
)
}
func
NewEphemeralKeyValueStore
()
*
EphemeralKeyValueStore
{
v
:=
&
EphemeralKeyValueStore
{
values
:
make
(
map
[
string
]
EphemeralStoreValue
),
}
v
.
expirator
=
NewExpirator
(
""
,
v
)
return
v
}
func
(
e
*
EphemeralKeyValueStore
)
Put
(
k
string
,
v
EphemeralStoreValue
,
lifespan
time
.
Duration
)
{
e
.
values
[
k
]
=
v
e
.
expirator
.
ExpireObject
(
ephemeralExpirationProxy
(
k
),
lifespan
)
}
func
(
e
*
EphemeralKeyValueStore
)
Get
(
k
string
)
(
v
EphemeralStoreValue
,
ok
bool
)
{
v
,
ok
=
e
.
values
[
k
]
return
}
func
(
e
*
EphemeralKeyValueStore
)
Delete
(
k
string
)
{
e
.
expirator
.
CancelObjectExpiration
(
ephemeralExpirationProxy
(
k
))
delete
(
e
.
values
,
k
)
}
func
(
e
*
EphemeralKeyValueStore
)
GetExpirable
(
id
ExpirableID
)
(
Expirable
,
error
)
{
_
,
ok
:=
e
.
values
[
string
(
id
)]
if
!
ok
{
return
nil
,
nil
}
return
ephemeralExpirationProxy
(
id
),
nil
}
func
(
e
*
EphemeralKeyValueStore
)
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