Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bahn-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
bahn-api
Commits
3f674159
Commit
3f674159
authored
6 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Maybe now cache will work?
parent
5bc6406e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
client.go
+8
-29
8 additions, 29 deletions
client.go
with
8 additions
and
29 deletions
client.go
+
8
−
29
View file @
3f674159
...
@@ -22,32 +22,11 @@ type ApiClient struct {
...
@@ -22,32 +22,11 @@ type ApiClient struct {
const
cacheTimestamp
=
"2006-01-02T15:04"
const
cacheTimestamp
=
"2006-01-02T15:04"
func
(
c
*
ApiClient
)
loadWithCache
(
key
string
,
result
interface
{},
load
func
()
(
interface
{},
error
))
error
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
break
}
_
=
targetCache
.
Set
(
key
,
result
)
}
return
nil
}
}
var
err
error
if
result
,
err
=
load
();
err
==
nil
{
for
_
,
cache
:=
range
c
.
Caches
{
_
=
cache
.
Set
(
key
,
result
)
}
}
return
err
}
func
(
c
*
ApiClient
)
Station
(
evaId
int64
)
([]
Station
,
error
)
{
func
(
c
*
ApiClient
)
Station
(
evaId
int64
)
([]
Station
,
error
)
{
key
:=
fmt
.
Sprintf
(
"realtime_recent %d"
,
evaId
)
key
:=
fmt
.
Sprintf
(
"realtime_recent %d"
,
evaId
)
var
result
[]
Station
var
result
[]
Station
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -94,7 +73,7 @@ func (c *ApiClient) Timetable(evaId int64, date time.Time) (Timetable, error) {
...
@@ -94,7 +73,7 @@ func (c *ApiClient) Timetable(evaId int64, date time.Time) (Timetable, error) {
var
result
Timetable
var
result
Timetable
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -142,7 +121,7 @@ func (c *ApiClient) RealtimeAll(evaId int64, date time.Time) (Timetable, error)
...
@@ -142,7 +121,7 @@ func (c *ApiClient) RealtimeAll(evaId int64, date time.Time) (Timetable, error)
var
result
Timetable
var
result
Timetable
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -189,7 +168,7 @@ func (c *ApiClient) RealtimeRecent(evaId int64, date time.Time) (Timetable, erro
...
@@ -189,7 +168,7 @@ func (c *ApiClient) RealtimeRecent(evaId int64, date time.Time) (Timetable, erro
var
result
Timetable
var
result
Timetable
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -236,7 +215,7 @@ func (c *ApiClient) WingDefinition(parent string, wing string) (WingDefinition,
...
@@ -236,7 +215,7 @@ func (c *ApiClient) WingDefinition(parent string, wing string) (WingDefinition,
var
result
WingDefinition
var
result
WingDefinition
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -283,7 +262,7 @@ func (c *ApiClient) CoachSequence(line string, date time.Time) (CoachSequence, e
...
@@ -283,7 +262,7 @@ func (c *ApiClient) CoachSequence(line string, date time.Time) (CoachSequence, e
var
result
CoachSequence
var
result
CoachSequence
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -330,7 +309,7 @@ func (c *ApiClient) Suggestions(line string, date time.Time) ([]Suggestion, erro
...
@@ -330,7 +309,7 @@ func (c *ApiClient) Suggestions(line string, date time.Time) ([]Suggestion, erro
var
result
[]
Suggestion
var
result
[]
Suggestion
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
@@ -398,7 +377,7 @@ func (c *ApiClient) HafasMessages(trainlink string) ([]HafasMessage, error) {
...
@@ -398,7 +377,7 @@ func (c *ApiClient) HafasMessages(trainlink string) ([]HafasMessage, error) {
var
result
[]
HafasMessage
var
result
[]
HafasMessage
for
_
,
cache
:=
range
c
.
Caches
{
for
_
,
cache
:=
range
c
.
Caches
{
if
err
:=
cache
.
Get
(
key
,
result
);
err
==
nil
{
if
err
:=
cache
.
Get
(
key
,
&
result
);
err
==
nil
{
for
_
,
targetCache
:=
range
c
.
Caches
{
for
_
,
targetCache
:=
range
c
.
Caches
{
if
targetCache
==
cache
{
if
targetCache
==
cache
{
break
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment