Skip to content

Commit 7425000

Browse files
authored
Updates for rc2 (#31)
* Rename NewNamedMap/Cache to GetNamedMap/Cache to better reflect their meaning * Fix sonarcloud * minor doc update
1 parent eba64e3 commit 7425000

File tree

41 files changed

+164
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+164
-163
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func main() {
9191
}
9292
defer session.Close()
9393
94-
// create a new NamedMap with key of int and value of string
95-
namedMap, err := coherence.NewNamedMap[int, string](session, "my-map")
94+
// get a NamedMap with key of int and value of string
95+
namedMap, err := coherence.GetNamedMap[int, string](session, "my-map")
9696
if err != nil {
9797
panic(err)
9898
}

coherence/doc.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Refer to the section on [NewSession] for more information on setting up a SSL co
6161
6262
# Obtaining a NamedMap or NamedCache
6363
64-
Once a session has been created, the [NewNamedMap](session, name, ...options) can be used to obtain
65-
an instance of a [NamedMap]. The key and value types must be provided as generic type arguments.
66-
This identifier may be shared across clients. It's also possible to have many [NamedMap]'s defined and in use simultaneously.
64+
Once a session has been created, the [GetNamedMap](session, name, ...options) or [GetNamedCache](session, name, ...options)
65+
can be used to obtain an instance of a [NamedMap] or [NamedCache]. The key and value types must be provided as generic type arguments.
66+
This identifier may be shared across clients. It's also possible to have many [NamedMap]s or [NamedCache]s defined and in use simultaneously.
6767
6868
Example:
6969
@@ -73,14 +73,14 @@ Example:
7373
}
7474
defer session.Close()
7575
76-
namedMap, err := coherence.NewNamedMap[int, string](session, "customers")
76+
namedMap, err := coherence.GetNamedMap[int, string](session, "customers")
7777
if err != nil {
7878
log.Fatal(err)
7979
}
8080
81-
If you wish to create a [NamedCache], which supports expiry, you can use the [NewNamedCache] function and then use the PutWithExpiry function call.
81+
If you wish to create a [NamedCache], which supports expiry, you can use the [GetNamedCache] function and then use the PutWithExpiry function call.
8282
83-
namedCache, err := coherence.NewNamedCache[int, string](session, "customers")
83+
namedCache, err := coherence.GetNamedCache[int, string](session, "customers")
8484
if err != nil {
8585
log.Fatal(err)
8686
}
@@ -91,7 +91,7 @@ If your [NamedCache] requires the same expiry for every entry, you can use the [
9191
Each call to Put will use the default expiry you have specified. If you use PutWithExpiry, this will override the default
9292
expiry for that key.
9393
94-
namedCache, err := coherence.NewNamedCache[int, Person](session, "cache-expiry", coherence.WithExpiry(time.Duration(5)*time.Second))
94+
namedCache, err := coherence.GetNamedCache[int, Person](session, "cache-expiry", coherence.WithExpiry(time.Duration(5)*time.Second))
9595
9696
See [SessionOptions] which lists all the options supported by the [Session] API.
9797
@@ -106,7 +106,7 @@ Assuming a very trivial [NamedMap] with integer keys and string values.
106106
log.Fatal(err)
107107
}
108108
109-
namedMap, err := coherence.NewNamedMap[int, string](session, "my-map")
109+
namedMap, err := coherence.GetNamedMap[int, string](session, "my-map")
110110
if err != nil {
111111
log.Fatal(err)
112112
}
@@ -151,7 +151,7 @@ if you wish to store structs as native Java objects, then please see the section
151151
}
152152
153153
// create a new NamedMap of Person with key int
154-
namedMap, err := coherence.NewNamedMap[int, Person](session, "test")
154+
namedMap, err := coherence.GetNamedMap[int, Person](session, "test")
155155
if err != nil {
156156
log.Fatal(err)
157157
}
@@ -161,7 +161,7 @@ if you wish to store structs as native Java objects, then please see the section
161161
log.Fatal(err)
162162
}
163163
164-
newPerson := Person{ID: 1, Name: "Tim", Age: 53}
164+
newPerson := Person{ID: 1, Name: "Tim", Age: 21}
165165
fmt.Println("Add new Person", newPerson)
166166
if _, err = namedMap.Put(ctx, newPerson.Id, newPerson); err != nil {
167167
log.Fatal(err)
@@ -195,7 +195,7 @@ Key and/or a Value. As always, the Err object must be checked for errors before
195195
All functions that return channels are EntrySetFilter, KeySetFilter, ValuesFilter,
196196
EntrySet, KeySet, Values, InvokeAll and InvokeAllFilter.
197197
198-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
198+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
199199
if err != nil {
200200
log.Fatal(err)
201201
}
@@ -234,7 +234,7 @@ run various scenarios to increase peoples salary by using a [processors.Multiply
234234
City string `json:"city"`
235235
}
236236
237-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
237+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
238238
239239
// 1. Increase the salary of the person with Id = 1
240240
newSalary, err = coherence.Invoke[int, Person, float32](ctx, namedMap, 1, processors.Multiply("salary", 1.1, true))
@@ -266,7 +266,7 @@ large amounts of data.
266266
To demonstrate this, lets assume we have a [NamedMap] populated with Person struct as per the previous example, and we want to
267267
run various scenarios to perform aggregations.
268268
269-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
269+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
270270
if err != nil {
271271
log.Fatal(err)
272272
}
@@ -296,7 +296,7 @@ that occur against a [NamedMap] or [NamedCache]. You can listen for all events,
296296
vents based upon a key.
297297
298298
// in your main code, create a new NamedMap and register the listener
299-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
299+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
300300
if err != nil {
301301
log.Fatal(err)
302302
}
@@ -359,7 +359,7 @@ that occur against a [NamedMap] or [NamedCache].
359359
360360
// consider the example below where we want to listen for all 'truncate' events for a NamedMap.
361361
// in your main code, create a new NamedMap and register the listener
362-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
362+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
363363
if err != nil {
364364
log.Fatal(err)
365365
}
@@ -373,7 +373,7 @@ that occur against a [NamedMap] or [NamedCache].
373373
namedMap.AddLifecycleListener(listener)
374374
defer namedMap.RemoveLifecycleListener(listener)
375375
376-
newPerson := Person{ID: 1, Name: "Tim", Age: 53}
376+
newPerson := Person{ID: 1, Name: "Tim", Age: 21}
377377
fmt.Println("Add new Person", newPerson)
378378
if _, err = namedMap.Put(ctx, newPerson.Id, newPerson); err != nil {
379379
log.Fatal(err)
@@ -421,7 +421,7 @@ in your main code, create a new [Session] and register the listener
421421
defer session.RemoveSessionLifecycleListener(listener)
422422
423423
// create a new NamedMap of Person with key int
424-
namedMap, err := coherence.NewNamedMap[int, Person](session, "people")
424+
namedMap, err := coherence.GetNamedMap[int, Person](session, "people")
425425
if err != nil {
426426
log.Fatal(err)
427427
}

coherence/named_cache_client.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (nc *NamedCacheClient[K, V]) Release() {
144144
//
145145
// The example below shows how to check if a [NamedCache] contains a mapping for the key 1.
146146
//
147-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
147+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
148148
// if err != nil {
149149
// log.Fatal(err)
150150
// }
@@ -160,7 +160,7 @@ func (nc *NamedCacheClient[K, V]) ContainsKey(ctx context.Context, key K) (bool,
160160
//
161161
// The example below shows how to check if a [NamedCache] contains a mapping for the person.
162162
//
163-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
163+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
164164
// if err != nil {
165165
// log.Fatal(err)
166166
// }
@@ -177,7 +177,7 @@ func (nc *NamedCacheClient[K, V]) ContainsValue(ctx context.Context, value V) (b
177177
//
178178
// The example below shows how to check if a [NamedCache] contains a mapping for the key 1 and person.
179179
//
180-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
180+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
181181
// if err != nil {
182182
// log.Fatal(err)
183183
// }
@@ -201,7 +201,7 @@ func (nc *NamedCacheClient[K, V]) IsEmpty(ctx context.Context) (bool, error) {
201201
//
202202
// The example below shows how to iterate the entries in a [NamedCache] where the age > 20.
203203
//
204-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
204+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
205205
// if err != nil {
206206
// log.Fatal(err)
207207
// }
@@ -225,7 +225,7 @@ func (nc *NamedCacheClient[K, V]) EntrySetFilter(ctx context.Context, fltr filte
225225
//
226226
// The example below shows how to iterate the entries in a [NamedCache].
227227
//
228-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
228+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
229229
// if err != nil {
230230
// log.Fatal(err)
231231
// }
@@ -245,7 +245,7 @@ func (nc *NamedCacheClient[K, V]) EntrySet(ctx context.Context) <-chan *Streamed
245245
// Get returns the value to which the specified key is mapped. V will be nil
246246
// if this [NamedCache] contains no mapping for the key.
247247
//
248-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
248+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
249249
// if err != nil {
250250
// log.Fatal(err)
251251
// }
@@ -269,7 +269,7 @@ func (nc *NamedCacheClient[K, V]) Get(ctx context.Context, key K) (*V, error) {
269269
//
270270
// The example below shows how to get all the entries for keys 1, 3 and 4.
271271
//
272-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
272+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
273273
// if err != nil {
274274
// log.Fatal(err)
275275
// }
@@ -298,7 +298,7 @@ func (nc *NamedCacheClient[K, V]) GetOrDefault(ctx context.Context, key K, def V
298298
//
299299
// The example below shows how to iterate the keys in a [NamedCache] where the age > 20.
300300
//
301-
// namedCache, err := coherence.NewNamedCache[int, Person](session,"people")
301+
// namedCache, err := coherence.GetNamedCache[int, Person](session,"people")
302302
// if err != nil {
303303
// log.Fatal(err)
304304
// }
@@ -322,7 +322,7 @@ func (nc *NamedCacheClient[K, V]) KeySetFilter(ctx context.Context, fltr filters
322322
//
323323
// The example below shows how to iterate the keys in a [NamedCache].
324324
//
325-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
325+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
326326
// if err != nil {
327327
// log.Fatal(err)
328328
// }
@@ -349,13 +349,13 @@ func (nc *NamedCacheClient[K, V]) Name() string {
349349
// is carried out in parallel and no previous values are returned.
350350
//
351351
// var peopleData = map[int]Person{
352-
// 1: {ID: 1, Name: "Tim", Age: 50},
352+
// 1: {ID: 1, Name: "Tim", Age: 21},
353353
// 2: {ID: 2, Name: "Andrew", Age: 44},
354354
// 3: {ID: 3, Name: "Helen", Age: 20},
355355
// 4: {ID: 4, Name: "Alexa", Age: 12},
356356
// }
357357
//
358-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
358+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
359359
// if err != nil {
360360
// log.Fatal(err)
361361
// }
@@ -392,7 +392,7 @@ func (nc *NamedCacheClient[K, V]) PutWithExpiry(ctx context.Context, key K, valu
392392
// Remove removes the mapping for a key from this [NamedCache] if it is present and
393393
// returns the previous value or nil if there wasn't one.
394394
//
395-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
395+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
396396
// if err != nil {
397397
// log.Fatal(err)
398398
// }
@@ -466,7 +466,7 @@ func (nc *NamedCacheClient[K, V]) Size(ctx context.Context) (int, error) {
466466
//
467467
// The example below shows how to iterate the values in a [NamedCache] where the age > 20.
468468
//
469-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
469+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
470470
// if err != nil {
471471
// log.Fatal(err)
472472
// }
@@ -490,7 +490,7 @@ func (nc *NamedCacheClient[K, V]) ValuesFilter(ctx context.Context, fltr filters
490490
//
491491
// The example below shows how to iterate the values in a [NamedCache].
492492
//
493-
// namedCache, err := coherence.NewNamedCache[int, Person](session, "people")
493+
// namedCache, err := coherence.GetNamedCache[int, Person](session, "people")
494494
// if err != nil {
495495
// log.Fatal(err)
496496
// }

0 commit comments

Comments
 (0)