UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '3CFJy5fCvoGZSJ21SAO58kI87vWu4168hyB0ALrJwN0='
WHERE
key_id = '7c3aeae6d7fde841c28f375fdd5930729f8f92e03897e62347059a46f03a37a9'
AND (
token = '3CFJy5fCvoGZSJ21SAO58kI87vWu4168hyB0ALrJwN0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)