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