Skip to content

Commit fbef14e

Browse files
committed
perf(cache) support in-memory and persisted cache
- enhance in-memory cache - add persisted cache with `HTML5_CACHE=1` flag - change `HTML5_RUNTIME_URL` default to `cpp` - try to use exisring `app-runtime` key before creating new one - update README.md - update CHANGELOG.md
1 parent 64c09aa commit fbef14e

File tree

8 files changed

+314
-47
lines changed

8 files changed

+314
-47
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [1.4.2] - 2020-05-19
910
### Added
11+
- Support of multiple destinations pointing to same business service in `html5-list -d` (MTA deployment flow)
1012
- Print time in trace logs
1113

14+
### Changed
15+
- Default `HTML5_RUNTIME_URL` is changed back to `https://<tenant>.cpp.<landscape_url>`
16+
1217
### Performance
1318
- In-memory cache for services and service plans
19+
- Persisted cache with `HTML5_CACHE=1`
1420

1521
## [1.4.1] - 2020-04-21
1622

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ OPTIONS:
229229
The configuration of the CF HTML5 Applications Repository CLI Plugin is done by using environment variables.
230230
The following are supported:
231231
* `DEBUG=1` - enables trace logs with detailed information about currently running steps
232+
* `HTML5_CACHE=1` - enables persisted cache. Disabled by default. Should be enabled only for sequential
233+
execution of the CF HTML5 Applications Repository CLI Plugin commands in the same context
234+
(org/space/user) during short period of time (less than 12 hours)
232235
* `HTML5_SERVICE_NAME` - name of the service in CF marketplace (default: `html5-apps-repo`)
233236
* `HTML5_RUNTIME_URL` - URL of HTML5 runtime to serve business service
234-
destinations (default: `https://<tenant>.launchpad.<landscape_url>`)
237+
destinations (default: `https://<tenant>.cpp.<landscape_url>`)
235238

236239
## Troubleshooting
237240

cache/memory.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ func Get(key string) (interface{}, bool) {
1414
func Set(key string, value interface{}) {
1515
cacheMap[key] = value
1616
}
17+
18+
// All dump cache
19+
func All() map[string]interface{} {
20+
return cacheMap
21+
}

commands/base_command.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package commands
22

33
import (
4-
"cf-html5-apps-repo-cli-plugin/log"
54
"fmt"
65

76
"github.com/cloudfoundry/cli/cf/terminal"
@@ -20,18 +19,27 @@ type BaseCommand struct {
2019
CliConnection plugin.CliConnection
2120
}
2221

23-
// Initialize initializes the command with the specified name and CLI connection
22+
// Initialize default initialization method which may be overriden in more specific commands
2423
func (c *BaseCommand) Initialize(name string, cliConnection plugin.CliConnection) {
25-
log.Tracef("Initializing command '%s'\n", name)
26-
c.InitializeAll(name, cliConnection)
24+
c.InitializeBase(name, cliConnection)
2725
}
2826

29-
// InitializeAll initializes the command with the specified name and CLI connection.
30-
func (c *BaseCommand) InitializeAll(name string, cliConnection plugin.CliConnection) {
27+
// InitializeBase initializes the command with the specified name and CLI connection.
28+
func (c *BaseCommand) InitializeBase(name string, cliConnection plugin.CliConnection) {
3129
c.Name = name
3230
c.CliConnection = cliConnection
3331
}
3432

33+
// Dispose default dispose method which may be overriden in more specific commands
34+
func (c *BaseCommand) Dispose(name string) {
35+
c.DisposeBase(name)
36+
}
37+
38+
// DisposeBase dispose command
39+
func (c *BaseCommand) DisposeBase(_ string) {
40+
// Do nothing
41+
}
42+
3543
// Context holding the username, Org and Space of the current used
3644
type Context struct {
3745
Username string

commands/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ type Command interface {
99
GetPluginCommand() plugin.Command
1010
Initialize(name string, cliConnection plugin.CliConnection)
1111
Execute(args []string) ExecutionStatus
12+
Dispose(name string)
1213
}

0 commit comments

Comments
 (0)