spring redis increment - spring

i want to substitute memcached for spring-redis.
memcached has function
* #param key key
* #param delta
* increment delta
* #param initValue
* the initial value to be added when value is not found
* #param timeout
* operation timeout
* #param exp
* the initial vlaue expire time, in seconds. Can be up to 30
* days. After 30 days, is treated as a unix timestamp of an
* exact date.
* #return
* #throws TimeoutException
* #throws InterruptedException
* #throws MemcachedException
*/
long incr(String key, long delta, long initValue, long timeout, int exp)
throws TimeoutException, InterruptedException, MemcachedException;
spring-redis has function
Long increment(K key, long delta);
how can i set operation timeout(not expire) in spring-redis?

spring-redis doesnt allow you to configure timeout per individual request (as in memcached realization). You can configure timeout per connection with a configuration setting in application.properties:
spring.redis.timeout=5000

Related

How to describe websocket api using Apidoc?

This issue "Documenting WebSockets #501"
said "apiDoc was not designed for websockets, but i think you can use it too. The #api /endpoint/path must be replaced with the function / message name, the parameters could be documented the same way."
This is my code :
/**
* #api onBinaryMessage Set a binary message handler on the connection.
*
* #apiGroup websocket
* #apiParam {Buffer} buffer
* #apiParam {ServerWebSocket} websocket
*/
result
Is there a standard usage? Orz

laravel migration error while creating new one

i tried creating new migration and in my migration file i got the following text
/**
* Gets the first element of `array`.
*
* #static
* #memberOf _
* #since 0.1.0
* #alias first
* #category Array
* #param {Array} array The array to query.
* #returns {*} Returns the first element of `array`.
* #example
*
* _.head([1, 2, 3]);
* // => 1
*
* _.head([]);
* // => undefined
*/
function head(array) {
return (array && array.length) ? array[0] : undefined;
}
module.exports = head;
instead of the normal migration code,
i tried installing the composer , composer dump-autoload
tried clearing cache
but still no luck , it was not like this earlier as i have created many migrations and they were working fine but suddenly it gave me this error,
any idea what is causing this error

Ignite - explain about 31100 time server port

Can anyone please explain, why the ignite is using the 31100 port. I have got the info in web as it is a time server port. I couldn't get anything other than this info.
I see following configuration options in Ignite project:
/** Base port number for time server. */
private int timeSrvPortBase = DFLT_TIME_SERVER_PORT_BASE; // 31100
/** Port number range for time server. */
private int timeSrvPortRange = DFLT_TIME_SERVER_PORT_RANGE; // 100
/**
* Gets base UPD port number for grid time server. Time server will be started on one of free ports in range
* {#code [timeServerPortBase, timeServerPortBase + timeServerPortRange - 1]}.
* <p>
* Time server provides clock synchronization between nodes.
*
* #return Time
*/
public int getTimeServerPortBase() {
return timeSrvPortBase;
}
/**
* Defines port range to try for time server start.
*
* If port range value is <tt>0</tt>, then implementation will try bind only to the port provided by
* {#link #setTimeServerPortBase(int)} method and fail if binding to this port did not succeed.
*
* #return Number of ports to try before server initialization fails.
*/
public int getTimeServerPortRange() {
return timeSrvPortRange;
}
But I don't see any usage of this methods in other places. Looks like and obsolete feature. I've just started one server node of 2.10 and didn't see any open ports in range 311xx (sudo netstat -atnp | grep 311[0-9][0-9] was empty). Are you sure that your Ignite instance exposes this port? What version do you use?

Why is php decimal-ext throwing an exception for wrong return type of compareTo method?

I've installed decimal-ext extension and php-decimal/laravel composer package. I'm using it to compare large decimal numbers. On my laptop everything works correctly but on my staging server the following error is thrown:
Return value of Decimal\Decimal::compareTo() must be of the type int, none returned
and here is the code:
(new Decimal($value))->compareTo($maxNumber) == -1;
As I said I'm not getting this error on my laptop.
Laravel: 5.8
PHP: 7.4.3
Server: Ubuntu 18.04
I spent some time on this but figured it out. The decimal-ext extension was not loaded in the server's php.ini file. Php didn't throw an exception about missing extension but about the wrong return type because the class Decimal was actually loaded (it was installed via the composer). I could instantiate an instance but the implementation was missing:
/**
* Ordering
*
* This method is equivalent to the `<=>` operator.
*
* #param mixed $other
*
* #return int 0 if this decimal is considered is equal to $other,
* -1 if this decimal should be placed before $other,
* 1 if this decimal should be placed after $other.
*/
public function compareTo($other): int {}

Laravel : Task Scheduling [ In Parallel ]

I have multiple tasks that need to be done every hour or two. All of them have been scheduled via Laravel using below comamnds as cron jobs
$schedule->command('email:notifications1')
->cron('15 * * * * *');
$schedule->command('email:notifications2')
->cron('15 * * * * *');
$schedule->command('email:notifications3')
->cron('15 * * * * *');
Issue:
All of the above tasks are pretty time consuming & it seems from the results that these tasks are not running in parallel. And each tasks runs after the previous has ended.
Requirment
How can i run them in parallel? I want all tasks to be executed (in parallel) as soon as the clock tick the specified time.
Laravel Version 5
You can easily have multiple parallel commands running if you add runInBackground() to the chain.
Like this:
$schedule->command('email:notifications1')
->cron('15 * * * * *')->runInBackground();
$schedule->command('email:notifications2')
->cron('15 * * * * *')->runInBackground();
$schedule->command('email:notifications3')
->cron('15 * * * * *')->runInBackground();
This creates a new process in the background so the Scheduler doesn't have to wait until the command executes. This doesn't even interfere with the withoutOverlapping() method because that works with mutex files.
Now you also have the benefit of having your commands in version control.
The Laravel scheduler can only run one command at a time because of the limitations of PHP.
You could, however, add the cronjobs directly in your crontab file, this way, they will be executed in parallel in separate processes.
15 * * * * * php /path/to/artisan email:notifications1
15 * * * * * php /path/to/artisan email:notifications2
15 * * * * * php /path/to/artisan email:notifications3
Another way to fix this is to let the jobs start at another time. Because a new php process is started every minute by the cron job, these do not affect each other.
For example:
$schedule->command('email:notifications1')
->cron('5 * * * * *');
$schedule->command('email:notifications2')
->cron('10 * * * * *');
$schedule->command('email:notifications3')
->cron('15 * * * * *');

Resources