@@ -61,9 +61,9 @@ Refer to the section on [NewSession] for more information on setting up a SSL co
61
61
62
62
# Obtaining a NamedMap or NamedCache
63
63
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.
67
67
68
68
Example:
69
69
@@ -73,14 +73,14 @@ Example:
73
73
}
74
74
defer session.Close()
75
75
76
- namedMap, err := coherence.NewNamedMap [int, string](session, "customers")
76
+ namedMap, err := coherence.GetNamedMap [int, string](session, "customers")
77
77
if err != nil {
78
78
log.Fatal(err)
79
79
}
80
80
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.
82
82
83
- namedCache, err := coherence.NewNamedCache [int, string](session, "customers")
83
+ namedCache, err := coherence.GetNamedCache [int, string](session, "customers")
84
84
if err != nil {
85
85
log.Fatal(err)
86
86
}
@@ -91,7 +91,7 @@ If your [NamedCache] requires the same expiry for every entry, you can use the [
91
91
Each call to Put will use the default expiry you have specified. If you use PutWithExpiry, this will override the default
92
92
expiry for that key.
93
93
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))
95
95
96
96
See [SessionOptions] which lists all the options supported by the [Session] API.
97
97
@@ -106,7 +106,7 @@ Assuming a very trivial [NamedMap] with integer keys and string values.
106
106
log.Fatal(err)
107
107
}
108
108
109
- namedMap, err := coherence.NewNamedMap [int, string](session, "my-map")
109
+ namedMap, err := coherence.GetNamedMap [int, string](session, "my-map")
110
110
if err != nil {
111
111
log.Fatal(err)
112
112
}
@@ -151,7 +151,7 @@ if you wish to store structs as native Java objects, then please see the section
151
151
}
152
152
153
153
// 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")
155
155
if err != nil {
156
156
log.Fatal(err)
157
157
}
@@ -161,7 +161,7 @@ if you wish to store structs as native Java objects, then please see the section
161
161
log.Fatal(err)
162
162
}
163
163
164
- newPerson := Person{ID: 1, Name: "Tim", Age: 53 }
164
+ newPerson := Person{ID: 1, Name: "Tim", Age: 21 }
165
165
fmt.Println("Add new Person", newPerson)
166
166
if _, err = namedMap.Put(ctx, newPerson.Id, newPerson); err != nil {
167
167
log.Fatal(err)
@@ -195,7 +195,7 @@ Key and/or a Value. As always, the Err object must be checked for errors before
195
195
All functions that return channels are EntrySetFilter, KeySetFilter, ValuesFilter,
196
196
EntrySet, KeySet, Values, InvokeAll and InvokeAllFilter.
197
197
198
- namedMap, err := coherence.NewNamedMap [int, Person](session, "people")
198
+ namedMap, err := coherence.GetNamedMap [int, Person](session, "people")
199
199
if err != nil {
200
200
log.Fatal(err)
201
201
}
@@ -234,7 +234,7 @@ run various scenarios to increase peoples salary by using a [processors.Multiply
234
234
City string `json:"city"`
235
235
}
236
236
237
- namedMap, err := coherence.NewNamedMap [int, Person](session, "people")
237
+ namedMap, err := coherence.GetNamedMap [int, Person](session, "people")
238
238
239
239
// 1. Increase the salary of the person with Id = 1
240
240
newSalary, err = coherence.Invoke[int, Person, float32](ctx, namedMap, 1, processors.Multiply("salary", 1.1, true))
@@ -266,7 +266,7 @@ large amounts of data.
266
266
To demonstrate this, lets assume we have a [NamedMap] populated with Person struct as per the previous example, and we want to
267
267
run various scenarios to perform aggregations.
268
268
269
- namedMap, err := coherence.NewNamedMap [int, Person](session, "people")
269
+ namedMap, err := coherence.GetNamedMap [int, Person](session, "people")
270
270
if err != nil {
271
271
log.Fatal(err)
272
272
}
@@ -296,7 +296,7 @@ that occur against a [NamedMap] or [NamedCache]. You can listen for all events,
296
296
vents based upon a key.
297
297
298
298
// 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")
300
300
if err != nil {
301
301
log.Fatal(err)
302
302
}
@@ -359,7 +359,7 @@ that occur against a [NamedMap] or [NamedCache].
359
359
360
360
// consider the example below where we want to listen for all 'truncate' events for a NamedMap.
361
361
// 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")
363
363
if err != nil {
364
364
log.Fatal(err)
365
365
}
@@ -373,7 +373,7 @@ that occur against a [NamedMap] or [NamedCache].
373
373
namedMap.AddLifecycleListener(listener)
374
374
defer namedMap.RemoveLifecycleListener(listener)
375
375
376
- newPerson := Person{ID: 1, Name: "Tim", Age: 53 }
376
+ newPerson := Person{ID: 1, Name: "Tim", Age: 21 }
377
377
fmt.Println("Add new Person", newPerson)
378
378
if _, err = namedMap.Put(ctx, newPerson.Id, newPerson); err != nil {
379
379
log.Fatal(err)
@@ -421,7 +421,7 @@ in your main code, create a new [Session] and register the listener
421
421
defer session.RemoveSessionLifecycleListener(listener)
422
422
423
423
// 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")
425
425
if err != nil {
426
426
log.Fatal(err)
427
427
}
0 commit comments