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