UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'jThY80Ebmx58ATRNfLTSmAdrfS4Rq7iN5G6wni6knq8='
WHERE
key_id = 'b410cda4bac7f6d5189476dab9d65f355490e901a382ef5fdd0bf1916e63b41b'
AND (
token = 'jThY80Ebmx58ATRNfLTSmAdrfS4Rq7iN5G6wni6knq8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)