UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hd6LscuzVohSY9akAfaz2cuBdTjkPC5cH4SZ8XyU8X4='
WHERE
key_id = '147d9d7625fb67af788eb739d8b87e003b3c68a1e1285a134ae7cb82260d5ba1'
AND (
token = 'hd6LscuzVohSY9akAfaz2cuBdTjkPC5cH4SZ8XyU8X4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)