UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ba7qDv2yyPHRREu+1H4PI2fyhw5SZRPYnNR4FqBwtOk='
WHERE
key_id = 'ca6f8edabba7b7208b9477f5f9667870ef72eee39c316dba651f52f79469015a'
AND (
token = 'ba7qDv2yyPHRREu+1H4PI2fyhw5SZRPYnNR4FqBwtOk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)